Validation/AutoPostBack Help Please

jr53080

New member
Joined
May 29, 2003
Messages
1
Location
Tucson, AZ
I have a webform that takes a date as input into a textbox. The textbox is validated using the Range Validator of type date. The problem is that i also call an AutoPostBack on the textbox for the event OnTextChanged. When the autopostback fires it negates the RangeValidator. What i need is when the date is valid .. it should AutoPostBack and when it is not valid then it would throw up the Validation Error and not post back until the Validation passes.

If anyone has any ideas, it would be really nice .. im thinking i need to do something with JavaScript but im not sure how to Reference objects in my C# and ASP pages..

THanks for the help
 
I never used the Range Validator but I assume that when a date is not valid it should not post back.
 
Yes, I agree with Robby. Validator control will generate both the client and server site validations, unless your browser cant support scripting, otherwise it should not postback if the user enter invalid date.

If you use javascript to do the date validation, then there may be a problem because you need to manual keep those controls value in every postback process. Currently .NET will handle it for you using Viewstate (if I not mistaken).
 
Sorry for my mistake, if you are using web controls, then you still can maintain your values.

What do you mean "im not sure how to Reference objects"? because web control also got its own ID, or you can give it a "Name", then use normal Javascript to handle it.
 
Back
Top