Can't do javacript when using masterpage in .Net 2.0

2 posts, 0 answers
  1. Alfred Ortega
    Alfred Ortega avatar
    193 posts
    Member since:
    May 2005

    Posted 09 Nov 2005 Link to this post

    I know this isn't a telerik caused problem it is an ASP.Net 2.0 issue so figure I'd ask it here since it involves a telerik control.  I am having a problem that is probably easy but has me stumped. I am using ASP.Net 2.0 and have a master page with a menu system and then pages inherit from it. But I have a page I would like to put javascript on to use the spellcheck on more than one element, which works fine in ASP.Net 1.1.

    I know on buttons I can add the attribute OnClientClick="return confirm('Are you sure')" but the script for multiple element spell checking is much more complex. If I put in a webcontrol everytime it runs it fails with an error saying my <head> tag needs the runat="server" attribute which the masterpage does have and I can't put it in a page that uses the master or the webcontrol since the head tag isn't allowed in either one...

    The problem seems to be how do you do client side javacript when you are using masterpages?

    Any and all suggestions are welcome...

    thanks in advance

  2. Shaun Peet
    Shaun Peet avatar
    571 posts
    Member since:
    Aug 2004

    Posted 28 Nov 2005 Link to this post

    You can put the javascript inside the <asp:content /> tags on your aspx pages.  For example,

    <asp:content id="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript">
        ' your script
    ' Your page content

    It gets a little tricky finding the ClientID() for the controls when matser pages are used, for example a button on the aspx page will end up with the ClientID of ctl00_ContentPlaceHolder1_Button1 if all the default IDs are in place.  Not sure if that answers your question, but perhaps it answers somebody else's.
Back to Top