| Author: Lakhan Pal 03 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi Arunramm-
You can Create RequiredFieldValidator using this Code:
RequiredFieldValidator req = new RequiredFieldValidator(); req.ErrorMessage = "Your Error Message Here."; req.ControlToValidate = "txtPrice"; req.SetFocusOnError = true; req.Display = ValidatorDisplay.Dynamic;
In the above code txtPrice is the name of your Control.
Please rate this answer if it helped you. Thanks & Regards Lakhan Pal Garg Free Code Snippets
|
| Author: jananeekar 03 Nov 2009 | Member Level: Silver | Rating:  Points: 2 |
RequiredFieldValidator req = new RequiredFieldValidator(); req.ErrorMessage = "Your Error Message Here."; req.ControlToValidate = "txtPrice"; req.SetFocusOnError = true; req.Display = ValidatorDisplay.Dynamic; form1.Controls.Add(req);
you need to just add the control to form control collections, it works but disappears in postbacks
|