I have an ASP.NET form where I have an ImageButton control as follows (please note that this only part of a bigger form):
<asp:CheckBox runat="server" ID="checkbox1" Text="Validate" Enabled="false" />
<asp:TextBox runat="server" ID="textbox1" MaxLength="30" />
<asp:RequiredFieldValidator ID="validator1" ControlToValidate="textbox1" Text="required!" runat="server" ValidationGroup="group1" />
<asp:ImageButton ID="button1" runat="server" Width="24" ValidationGroup="group1" />
Using Javascript, I could disable and enable the RequiredFieldValidator as follows:
function test() {
var checkbox1 = document.getElementById("<%=checkbox1.ClientID %>");
var ckOwnerIsOperator = document.getElementById('<%=ckOwnerIsOperator.ClientID %>');
if (checkbox1.checked)
ValidatorEnable(validator1, false);
}
What I am looking for is an event that fires before the validation on the button when the button is clicked. I know I could do this on checkbox click event, but it is not what I need. The checkbox click event has a problem where I lose the validator state if another control triggered an async postback, so I want the test() function to be called before the page validation occurs.
Thank you all