hooking into the validation summary control, adding a custom errormessage

  • Thread starter Thread starter DotNetNewbie
  • Start date Start date
D

DotNetNewbie

Hello,
I have a validation summary tag in my .aspx page, and when a user
clicks on a submit button I check the database for a duplicate
username that the user entered into a textbox control.

If I find a duplicate username in the database, I want to insert a
message into the validationsummary control like "username already
exists, please enter a different username".

How can I do this?
 
Hello DotNetNewbie,
Hello,
I have a validation summary tag in my .aspx page, and when a user
clicks on a submit button I check the database for a duplicate
username that the user entered into a textbox control.
If I find a duplicate username in the database, I want to insert a
message into the validationsummary control like "username already
exists, please enter a different username".

How can I do this?

Add a CustomValidator control to your page. Set the error message and text
property as you would do with any other validator. Now go to the events tab
and implement the ServerValidate event to go to the database. you need to
set the eventargs.valid property to false to show the error.

It resets automatically each post, so you don't need to add logic for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top