How do I tie a control to a JavaScript function

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jason (nfr_at_nospam.com)
Date: 09/14/04


Date: Tue, 14 Sep 2004 10:00:17 -0700

I'm new to WebForms and struggling with very basic stuff at the moment. I am
trying to figure out how to detect a radiobutten click state using
JavaScript.

The following OnCheckedChanged code fails at runtime:

<HTML>

<HEAD>

   <title>WebForm1</title>

   <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

   <meta content="C#" name="CODE_LANGUAGE">

   <meta content="JavaScript" name="vs_defaultClientScript">

   <meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">

</HEAD>

   <body>

      <form id="Form1" method="post" runat="server">

         <P>

         <asp:RadioButton id="RadioButton1" runat="server" Checked="True"
Text="Purchase" GroupName="rb3"></asp:RadioButton><BR>

         <asp:RadioButton id="RadioButton2" runat="server" Text="Refi"
GroupName="rb3" OnCheckedChanged="changed(this);"></asp:RadioButton></P>

         <P>

      </form>

   <SCRIPT>

      function changed(rb){

         document.write("Click event");

      }

   </SCRIPT>

       </P>

</body>

</HTML>


Quantcast