Thursday, April 22, 2010

How to add Server side code in SharePoint content pages

 
 

As we will see in SharePoint 2003, it was not possible to add a simple piece of server side code in the content pages. But in SharePoint 2007 adding server side code to the content pages is possible. This can be achieved by modifying the web.config file. In the web.config file you can find <PageParserPaths> tag where we need to add some lines of code.

<SharePoint>

    <SafeModeMaxControls="200"CallStack="false"DirectFileDependencies="10"TotalFileDependencies="50"AllowPageLevelTrace="false">

      <PageParserPaths>

        <PageParserPathVirtualPath="/*"CompilationMode="Always"AllowServerSideScript="true"IncludeSubFolders="true" />

      </PageParserPaths>

    </SafeMode>

    .

    .

    .

</SharePoint>

 
 

You can also change the VirtualPath depending upon the requirement just like if you want to add server side code in the content pages for  a specific List/Library, then you can change the VirtualPath as "/List/TestCustomList/*"

0 comments: