Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

Yes, I agree with Robby. Validator control will generate both the client and server site validations, unless your browser can't 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).

Posted

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 it's own ID, or you can give it a "Name", then use normal Javascript to handle it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...