If you have a developer background, your company uses Sharepoint and
they want you add a lot of functionalities to that Sharepoint instance,
by nature as a programmer you will try to modify the aspx files and use
your choice of .Net language. So you started to download Sharepoint
desinger and have a look on what’s running under the hood and how to
modify it.
After downloading Sharepoint designer it also occured to you that you can create custom forms as when you right click on Site pages, you can add an aspx file.
Now you added your new file and excited to do coding so you tried modify your new aspx file to look like this:
An error occurred during processing of “YOUR PAGE URL”. Code blocks are not allowed in this file.
Your first reaction is WTF, you let me do the coding but you it wont allow me to run it.
To be able to code in Sharpoint you need to enable it on web config. To enable it go to your WSS Virtual Directory. The default directory is C:\inetpub\wwwroot\wss\VirtualDirectories\80 and modify your web.config (back it up first).
Now under Configuration –> Sharepoint –> SafeMode –> PageParserPaths add a new section for PageParserPath.
To enable code blocks on a Folder do a wildcard like such
After downloading Sharepoint designer it also occured to you that you can create custom forms as when you right click on Site pages, you can add an aspx file.
Now you added your new file and excited to do coding so you tried modify your new aspx file to look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <%@ Page Language="C#" %> <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta name="WebPartPageExpansion" content="full" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled 1</title> </head> <body> <form id="form1" runat="server"> </form> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Response.Write("Enable Code Blocks"); } </script> </body> </html>Then you tried to browse on it and this appears:
An error occurred during processing of “YOUR PAGE URL”. Code blocks are not allowed in this file.
Your first reaction is WTF, you let me do the coding but you it wont allow me to run it.
To be able to code in Sharpoint you need to enable it on web config. To enable it go to your WSS Virtual Directory. The default directory is C:\inetpub\wwwroot\wss\VirtualDirectories\80 and modify your web.config (back it up first).
Now under Configuration –> Sharepoint –> SafeMode –> PageParserPaths add a new section for PageParserPath.
To enable code blocks on a Folder do a wildcard like such
<PageParserPath VirtualPath="/TeamSite/CustomForms/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>Otherwise, indicate a file like such
<PageParserPath VirtualPath="/TeamSite/CustomForms/Test.aspx" CompilationMode="Always" AllowServerSideScript="true" />Now there are some additional properties you can assign like CompilationMode, AlowServerSideScript and IncludeSubFolders and I guess the two latter parts are self explanatory but for CompilationMode you have the following options:
- Always – The default value, which compiles the page always
- Auto – Page will not be compiled if possible
- Never – The page will not be dynamically compiled
No comments:
Post a Comment