Question

I have put a range validator in a asp.net text box control in my webpage; whenever the range is not meeting ; it will dispay the error message,

But it is moving to the next page. how i can prevent it from moving to the next page after the click of submit button while the range not met??

Was it helpful?

Solution

  • Make sure your submit button is in the same ValidationGroup as your range validator. This is particularly true if you have more than one ValidationGroup defined.

  • Make sure the property CausesValidation is not set to false on the button. The default value is True so if the property is not declared in your ASPX or code behind, the button should fire your validation sequence.

  • If you are not using the normal page flow, (i.e. your button has the property UseSubmitBehvior set to False, or in some cases, when using asych AJAX callbacks) then you will want to wrap your page changing code in an If block which checks for Page.IsValid before firing.

  • Double check that the ControlToValidate is set to the correct control and that it does not have a default value which passes the validation.

OTHER TIPS

Code?

Are you submitting directly to the next page rather than posting back to the same page and redirecting?

Are you redirecting in Page_Load, which occurs before validation?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top