Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 option buttons and a submit button. A comment(a text box) must be provide if option A is selected. How can I disable the validation when Option B is selected?

I read on http://msdn.microsoft.com/en-us/library/aa479045.asp that you can override the Validate method of the Page and switch it off from there but that didn't seem to work for me, didn't go into my break point.

C#
protected override void Validate()
{
    this.rfvComment.Enabled = this.optDecline.Checked;
    base.Validate();
}


Does anyone have any ideas how I can achieve this or why the above code isn't working?
Posted
Comments
Sunasara Imdadhusen 28-Oct-10 2:36am    
Are you using ASP.Net validation control?

1 solution

Hi,

Enable or Disable ASP.Net Validation on client side
rfvOther: is a Required Field Validator
XML
//Syntax:
ValidatorEnable(ValidatorContronName,Boolean);
//Explanation:ValidatorContronName – This is ClientID of the Validation control.
Boolean - true(Enable) / false(Disable)
//Example:
ValidatorEnable(document.getElementById('<%=rfvOther.ClientID%>'), fale);


You can implement this function according you logic.


Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen
 
Share this answer
 
Comments
Sandeep Mewara 28-Oct-10 3:30am    
Comment from OP:
Hi,

Yes, I using a RequiredFieldValiator. Where would you call ValidatorEnable()?
Dalek Dave 28-Oct-10 3:45am    
Good Call.
Sunasara Imdadhusen 28-Oct-10 4:19am    
Provide your code snippet, wherever you want required to enable/disable like button click or anything else

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900