1

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?

4 Answers 4

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

See Validating Form Input Controls.

I found this tutorial at http://social.msdn.microsoft.com/Search/en-US/?query=asp.net%20validation&ac=8.

Comments

0

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

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

Comments

0

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

Short but true =)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.