hooking into the validation summary control, adding a custom errormessage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DotNetNewbie

    hooking into the validation summary control, adding a custom errormessage

    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 validationsumma ry control like "username already
    exists, please enter a different username".

    How can I do this?
  • Jesse Houwing

    #2
    Re: hooking into the validation summary control, adding a custom error message

    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 validationsumma ry 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.


    --
    Jesse Houwing
    jesse.houwing at sogeti.nl


    Comment

    Working...