borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Web Server Controls and HTML Server Controls)Next Topic (what are the new features available in visual studio.net 2003 ?) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : dynamic page generation related question ?
Poster Message
tri_inn
Level: Regular User
Registered: 26-08-2002
Posts: 395

icon dynamic page generation related question ?

say suppose i have developed a form with the asp.net technology and there is five textboxes for fields like first name,last name,age,salary,mail id and all the fields are mandatory.
when user forget to fill up any fileds then form will not be submitted and those empty filled will come back again for filling up.say suppose user forget to fill up first name and salary then form will not be submitted and textboxes for first name and salary will come back again one after another for filling up.please tell me how can do it.

22-01-2004 at 12:16 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: dynamic page generation related question ?

The method that ASP.NET provides to deal with this issue is via controls or components called validators.

There are different types of validators such as RequiredFiedValidators, Compare Validator and REgular expresion validators.

A simple example for a required field is this:
- Place a required field validator next to the textbox representing the required field.
- Change the .Text property of the validator to *.
- Change the .ErrorMessage text to something like "Everybody must have a first name, put yours in the box."

- Set the .ControlToValidate property of the validator to the name of the control you want to validate txtFirstName for instance.
- At the end/bottom of the form, place a Validation summary control on the form.

Run the application. When you click the submit button without entering your name, a red asterisk (*) appears next to the text box and at the bottom of the page will be the text :
"Everybody must have a first name, put yours in the box."

You can have as many of these validators on your form as ...OK as sense will allow. When the form is submitted, validation takes place before your submit code is run. The validation summary is displayed and you live happily ever after because you will not get invalid/incomplete (hopefully) state information from your page. All this happens without you writing a line of code for validation.

Happy coding(or not)


____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

22-01-2004 at 05:33 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 439
icon Re: dynamic page generation related question ?

The method that ASP.NET provides to deal with this issue is via controls or components called validators.

There are different types of validators such as RequiredFiedValidators, Compare Validator and REgular expresion validators.

A simple example for a required field is this:
- Place a required field validator next to the textbox representing the required field.
- Change the .Text property of the validator to *.
- Change the .ErrorMessage text to something like "Everybody must have a first name, put yours in the box."

- Set the .ControlToValidate property of the validator to the name of the control you want to validate txtFirstName for instance.
- At the end/bottom of the form, place a Validation summary control on the form.

Run the application. When you click the submit button without entering your name, a red asterisk (*) appears next to the text box and at the bottom of the page will be the text :
"Everybody must have a first name, put yours in the box."

You can have as many of these validators on your form as ...OK as sense will allow. When the form is submitted, validation takes place before your submit code is run. The validation summary is displayed and you live happily ever after because you will not get invalid/incomplete (hopefully) state information from your page. All this happens without you writing a line of code for validation.

Happy coding(or not)


____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

22-01-2004 at 05:34 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : ASP.Net : dynamic page generation related question ?
Previous Topic (Web Server Controls and HTML Server Controls)Next Topic (what are the new features available in visual studio.net 2003 ?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder