How to use Inline Code In SharePoint Designer 2010?


SharePoint 2010 does not allow inline coding for Form pages created from SP Designer. If you use inline coding in any form page (New, Edit or Display), you will get into an error which will say “Code Block is not allowed on this page”.

To resolve this, you need to change the web.config file of your web application.

For example: If your web application uses Port 80,  you have to go to to port 80 directory which generally resides in C:\inetpub\wwwroot\wss\VirtualDirectories\80

go inside that port number directory where you will find the web.config file where you will need to modify. Look for the tag <PageParserPaths> in the web.config.

Now, if you want to allow inline coding for all the site collections under that web application you will need to add the following:

<PageParserPaths>
        <PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>

Now, above code will allow inline coding in all the form pages in SharePoint Designer 2010 under that particular web application across all the site collections and sites. Use IncludeSubFolders=”true” if you want that coding enabled for all the site collections or sites under that web app.

If you want to allow inline coding only for a particular site collection you will need to change the code to the following:

<PageParserPaths>
        <PageParserPath VirtualPath="/sites/sitename/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
 </PageParserPaths>

 

For a particular page inside a site or site collection:

<PageParserPaths>
        <PageParserPath VirtualPath="/sites/sitename/PageName.aspx" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>

Change the PageName.aspx to your page name.

For master page of your root level site collection:

<PageParserPaths>
    <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s