Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Skip Validation when Certain Button clicked? 1

Status
Not open for further replies.

romh

Programmer
Jan 3, 2003
297
US
Hi, I have form validation in an aspx page. Everything works fine except that in this page (its the page where he puts first name, last name etc...), I include a button which allows the user to go back and change the item (shopping cart item) that he has chosen. If the user has not filled the form completely according to validation rules, the code which opens the change item page, will not fire, because the validation does not allow it.
The code that switches back to the change item screen uses the Server.Transfer method. Here it is.

if(Page.IsValid || !Page.IsValid)
{
Session["Pointer"] = "CustomerInfo.aspx";
Server.Transfer("SelectPlan.aspx");
}

I tried adding tyhe Page.IsValid stuff, but that didn;t help.

Thanks
 
By having validation controls on your page, you are saying that every field must be validated before the form is allowed to be submitted to the server. You are therefore contradicting this by saying there is a situation where I do want the form to be submitted (even if it is just to transfer them to another page).

If you want the form to be submitted when certain fields may not be complete then you will have to remove the validation controls for them (they can still be validated on the server as you can write your own custom validation).

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I guess you are correct. I just thought that there was some way of forcing the page to ignore the validation controls. Considering that there the IsValid property exists.
 
You can check if a page is valid (Page.IsValid) but it obviously has to be submitted to the server for this to be checked - in you case it isn't being submitted therefore you can't check.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
What I did is I took the client side asp.net validation off the page, and instead used my own server side check. I just need to check for text boxes not beeing empty, and a valid email address. I accomplished the email address via the
Regex(strRegex)

method. Do any of you know where I can find off the web some validation for a valid credit card number (One that checks algorithm). There are many, but a reliable and easy one to get going would be nice.

 
Thanks alot. I had not found that article before. Seems pretty straightforward and simple. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top