Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally required field validation 1

Status
Not open for further replies.

Dhinga

Programmer
Jun 15, 2006
9
US
My requirement is that on the ASPX page, a text box is only required if certain condition is satisfied. I have created a Custom Validation control to do this. But if I keep the value of the text box then the "ServerValidate" event of the Custom Validation control is not fired. How do I do this kind of validation using C#?

Thanks
Hitesh Kapadia
 
What do you mean "keep the value"? Also, are you using VS.NET 2003 or VS 2005?

If 2005, just make sure the proper property is set to fire validation if the input is blank. Otherwise, for 2003 you'll have to create a validator inheriting from BaseValidator because the CustomValidator won't fire validation for blank input.
 
I am sorry. I meant to say; if I keep the value blank then the event is not fired as you have also mentioned. I am using VS 2005. Which property needs to be set to fire the "ServerValidate" event even when the input is blank.

Thanks
Hitesh
 
I found the propery & it is working fine now. Thanks for pointing it though.

Thanks
Hitesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top