C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

How to create required field validation dynamically


Posted Date: 03 Nov 2009      Posted By: Arunraam      Member Level: Silver     Points: 1   Responses: 2



Dear friends,
I want to dynamically create required field validation or other validation from class file .

Any idea !

Regards,
Arunraam





Responses

Author: Lakhan Pal    03 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     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 2009Member Level: SilverRating: 2 out of 52 out of 5     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



Post Reply
You must Sign In to post a response.
Next : Problem with Alert message window's Position
Previous : Browser Compatibilty with IE6,7,8 & mozilla
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use