giovedì 30 agosto 2012

How to add a script inline in a SharePoint 2010 Application Page

By default, adding inline code into an application page is forbidden for security reasons.
This behavior can be changed by editing the web.config configuration file for the IIS Web Application.
Look for the SafeMode element and add a child element that looks like the following one:

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

In this way allow the server side scripts on all the paths.
Then we can edit an application page using by SharePoint Designer 2010 (Home Ribbon, Editing Menu,
Advanced Mode)

<script type="text/c#" runat="server">
protected override void OnLoad(EventArgs e)
   //some actions here

Nessun commento:

Posta un commento