JavaScript in Content Page error

Discussion in 'ASP .Net' started by Steven K, Sep 9, 2004.

  1. Steven K

    Steven K Guest

    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.

    --
    Thanks in advance,

    Steven
     
    Steven K, Sep 9, 2004
    #1
    1. Advertising

  2. Steven K

    shikhachandrawanshi

    Joined:
    Apr 7, 2009
    Messages:
    1
    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
     
    shikhachandrawanshi, Apr 7, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J.Edwards
    Replies:
    0
    Views:
    1,691
    J.Edwards
    Jan 20, 2006
  2. hazz
    Replies:
    6
    Views:
    49,917
    SkyUCHC
    Jun 9, 2010
  3. Replies:
    0
    Views:
    749
  4. Rolf Welskes
    Replies:
    7
    Views:
    999
    Steven Cheng[MSFT]
    Aug 22, 2006
  5. Dave L
    Replies:
    3
    Views:
    3,323
    Göran Andersson
    Mar 4, 2010
Loading...

Share This Page