This is a migrated thread and some comments may be shown as answers.

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

1 Answer 95 Views
Miscellaneous
This is a migrated thread and some comments may be shown as answers.
Alfred Ortega
Top achievements
Rank 2
Alfred Ortega asked on 09 Nov 2005, 05:37 PM
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

Al

1 Answer, 1 is accepted

Sort by
0
Shaun Peet
Top achievements
Rank 2
answered on 28 Nov 2005, 05:00 PM
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
</script>
' Your page content
</asp: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.
Tags
Miscellaneous
Asked by
Alfred Ortega
Top achievements
Rank 2
Answers by
Shaun Peet
Top achievements
Rank 2
Share this question
or