C
Chris Walls
I have a CheckBox that when clicked, needs to first invoke a client-side
JavaScript function, then post back to the server. My ASP.NET code looks
like the following:
<asp:CheckBox ID="MyCheckBox" Runat="server" AutoPostBack="True"
OnCheckedChanged="OnMyCheckBoxCheckedChanged" />
I normally add JS code to a control by executing the following code in the
Page_Load method:
MyCheckBox.Attributes.Add("onclick", "DoSomethingFirst();");
However, the DoSomethingFirst() JS call is added to the generated SPAN tag
that surrounds the checkbox control, so my "DoSomethingFirst" function fires
*after* the AutoPostBack fires. How can I get my JS function to fire
*before* the AutoPostBack fires?
Thanks,
Chris
JavaScript function, then post back to the server. My ASP.NET code looks
like the following:
<asp:CheckBox ID="MyCheckBox" Runat="server" AutoPostBack="True"
OnCheckedChanged="OnMyCheckBoxCheckedChanged" />
I normally add JS code to a control by executing the following code in the
Page_Load method:
MyCheckBox.Attributes.Add("onclick", "DoSomethingFirst();");
However, the DoSomethingFirst() JS call is added to the generated SPAN tag
that surrounds the checkbox control, so my "DoSomethingFirst" function fires
*after* the AutoPostBack fires. How can I get my JS function to fire
*before* the AutoPostBack fires?
Thanks,
Chris