Skip Ribbon Commands
Skip to main content

Title

How to run inline code in SharePoint aspx pages

Comments

Say you want to add some code like this into a SharePoint Web Part Page

<%
         Server.Transfer(@"/_layouts/listfeed.aspx?List={D5813C18-934F-4FD6-9068-5CDD59CE56BA}");
%>

If you try and view the page you will get an error saying "An error occurred during the processing of xxx.aspx. Code blocks are not allowed in this file".To enable this you need to modify the web.config file for your SharePoint Site Collection.
To enable code blocks in single files, add the following section...

<PageParserPaths>

  <PageParserPath VirtualPath="/pages/blog.aspx" CompilationMode="Always" AllowServerSideScript="true" />

</PageParserPaths>

 To specify all files in a path (Document Library) the path statement can include a wild card (*) in which case you can also add IncludeSubFolders="true" parameter to the PageParserPath to allow inline code for any page.

Rating

0

Technology

 

Platform

WSSv3; MOSS 2007

Highlight

No

Author

Ian Morrish

URLStatus

 

Month

(1) - January

Year

2,007

Rating (0-5)

Current average rating is 3 stars. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.

Number of Ratings

1

Attachments

Content Type: Tips and Tricks
Created at 15/01/2007 9:22 a.m. by Ian Morrish
Last modified at 4/05/2008 10:59 p.m. by Ian Morrish