Click here to Skip to main content
15,889,852 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
I'm developing a Webform that displays a newsletter. At the bottom the newsletter, there is a comment textbox to allow the user to post a comment. I have a RequiredFieldValidator attached to the comment box to prevent empty comments from being posted.

All is working fine but I'm trying to add a "Sign Up" function so the user can register their e-mail address to receive the newsletter in their inbox.
The "Sign Up" functionality consists of:
* txtEmailAddress,
* RequiredFieldValidator for txtEmailAddress
* btnSignUp
Now when btnSignUp is clicked, the RequiredFieldValidator for txtComments will not allow the page to postback!

I know an easy solution would be to redirect the user to another page for registering and set btnSignUp property: CauseValidation to false. I guess I'm too bull headed but I want to give the user the quick access of signing up on the newsletter page! Is there any way besides a lot of javascript to accomplish this?

Thanks,
Richard

Posted

You can set the validation group so the signup fields don't trigger the validation for the comment field
http://msdn.microsoft.com/en-us/library/ms227424.aspx[^]

 
Share this answer
 
Richard Blythe wrote:
The "Sign Up" functionality consists of:
* txtEmailAddress,
* RequiredFieldValidator for txtEmailAddress
* btnSignUp
Now when btnSignUp is clicked, the RequiredFieldValidator for txtComments will not allow the page to postback!

You need to create the ValidationGroup for it. RequiredFieldValidator for txtEmailAddress , txtEmailAddress and btnSignUp should be under same validation group. :-D

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900