views:

73

answers:

4
+1  Q: 

ASP.NET Validation

i have one page to design. in this it includes an , password text box, My requirment is that when an user hit the submit button without entering any data, then it shows a message in red color at side of both the text box as "Cannot be empty" How it can be done without using Javascript?

A: 

You can use validation controls. They support client side and server side validation.

You don't need to know javascript if you mean that.

Canavar
A: 

In ASP.Net you can have Validators. http://www.dotnetcurry.com/ShowArticle.aspx?ID=121&AspxAutoDetectCookieSupport=1

Short but true =)

Kovu
+2  A: 

In this instance you would use a RequiredFieldValidator control, drop that in your page. It will by default use javascript and server side. You can turn the javascript off by setting the EnableClientScript property to false. You'd associate this validator with your text box using the ControlToValidate property. Set the Text property to the message you want to display.

On the server side event generated by your button simply call the Page's IsValid property and only if it is valid continue processing.

Steve Temple