Results 1 to 5 of 5

Thread: [RESOLVED] firing javascript on OnCheckChanged radiobutton event

  1. #1

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Resolved [RESOLVED] firing javascript on OnCheckChanged radiobutton event

    I have some javascript that I'm trying to fire off when the checked status of a radiobutton is changed. its suppose to uncheck any checkboxes that are checked on my page. the checkboxes are named CheckBox1, CheckBox2, etc. Here is my javascript

    Code:
    	<script type = "text/javascript">
    	function uncheckAll() 
    			{
    				for (var j = 1; j <= 14; j++) 
    				{
    					box = eval("document.Form1.CheckBox" + j); 
    					if (box.checked == true) box.checked = false;
    				}
    			}
           </script>
    and here is my code in my html:

    Code:
    <asp:RadioButton id="OptionButton3"  OnCheckedChanged="uncheckAll()" runat="server" Text="CONCENTRIC OR COMPRESSED" GroupName="CableType"></asp:RadioButton>
    But when I load the page i get this error:


    Compiler Error Message: BC30456: 'uncheckAll' is not a member of 'ASP._500_10_aspx'.



    I'm coding in VS.net. Why can't it recognize it?
    Thank you!
    Last edited by drpcken; Oct 21st, 2005 at 05:54 PM.

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: firing javascript on OnCheckChanged radiobutton event

    You cannot execute client side script by using a tag within a server side object.

    Therefore, make the radio button like this:
    <asp:RadioButton id="OptionButton3" runat="server" Text="CONCENTRIC OR COMPRESSED" GroupName="CableType"></asp:RadioButton>

    Then, in the Page_Load event, do the following Response.Write:
    Response.Write("<sc" + "ript lang=\"javascript\" for=\"" + OptionButton2.clientID + "\" event=\"OnCheckChanged\">uncheckAll()</sc" + "ript>");
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Re: firing javascript on OnCheckChanged radiobutton event

    Well I changed the OnCheckChanged event to OnClick (even though VS.NET doesn't like it and underlines it) and it worked perfectly.

    Which is better?

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: firing javascript on OnCheckChanged radiobutton event

    OnClick working for you, provided it continues, is a fluke.

    If it is, indeed, working, then ignore the underline and keep going.

    For future reference, make sure the code above is easily accessable for you.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  5. #5

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Re: firing javascript on OnCheckChanged radiobutton event

    Thanks again! I'll be back soon with more questions I'm sure.

    Thanks for eveything!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width