JavaScript in Content Page error

S

Steven K

Hello,

I have a Master Page with ContentPlaceHolders. I also have a content page
which I need to add some JavaScript to. If I place the JavaScript in the
content page, I get the following error:

Parser Error Message: Only Content controls are allowed directly in a
content page that contains Content controls.

However, if I place the script in the Master Page, the script works fine.
Is there a way to place JavaScript in the content page? I don't want to
have to place all of my JavaScript in the Master Page.
 
Joined
Apr 7, 2009
Messages
1
Reaction score
0
Hi,

solution is :

Add <asp:ContentPlaceHolder /> in the <head> of your master page, and put your script code in a content page with this Place Holder Id.


Master Page :
<head runat="server">
<asp:contentplaceholder id="ContentPlaceHolderScript" runat="server" />

</head>

ASPX Page :

<asp:Content ContentPlaceHolderID="ContentPlaceHolderScript" runat="server" ID="script1">
<script type="text/javascript">
</script>
</asp:Content >

Regards,
Shikha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top