Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I couldn't use javascript on my page, have "Code blocks are not allowed in this file". I added

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

into C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config on my Server, by nothing changed. Help plz, what's the problem?

share|improve this question
    
where is the page located? Master Page gallery? –  Falak Mahmood Feb 21 '12 at 8:37
add comment

3 Answers 3

Are you trying to use <script/> blocks with the runat attribute set to true - which means that the script should be executed on the server side, or are you trying to just do client side JavaScripts?

If it is the first one, I strongly discourages you to do it this way. Allowing code blocks like this and modifying the web.config file to allow it is opening your farm up for all kinds of vulnerabilities and performance degradation. There is a reason for this being prohibited by default. If you really need code running in the pages, make a real codebehind solution. That is create a class deriving from Page (or any of the SharePoint derivatives).

If it's the latter case, remove the runat="true" attribute on your script tags.

share|improve this answer
add comment

If you're using Master Page Gallery, please use

VirtualPath="/_mpg/*"

share|improve this answer
add comment

Use the following code if your Page layouts are located in the Master Page Gallery.

 <PageParserPaths>
        <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" />
 </PageParserPaths>
share|improve this answer
    
No, I try to use Code at custom aspx page, not at master page. –  kamax70 Feb 21 '12 at 10:50
    
it will work if your page layouts are existing in Master page gallery –  Falak Mahmood Feb 21 '12 at 11:47
    
or is your page layout located in Layouts folder? –  Falak Mahmood Feb 21 '12 at 11:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.