2009/05/16

C#- Validate before post back?

Recently I am working on SIMS (Safety Information Management System) and encountered a problem. The problem might make me sounds like a newbie but, yes, I am :).

So the problem is:
I have a textbox only accept numbers with no decimal and no letters, and I also set this textbox to auto postback so once the user enter a number and it will calculate the number with a formula.

Solution:
I have a validator with the needed regular expression pointed to that text box, all you have to do is click on the textbox and switch to html view and add in this: CausesValidation = "true", it will then check the textbox value and it must be true before doing the autopostback. Work like a charm ;)

No comments:

Post a Comment