Hello,
I have an ASP.NET HTML form control with multiple
HTML input button controls each of which has an
associated HTML input control. For each HTML
input control I have a validator that checks
that the input value is greater than zero.
But I want zero to be displayed within the
text field and want the validator to run
only when the corresponding button is
pressed.
Basically my form looks like this:
Quantity A: [ 0 ]
[Submit Button A]
Quantity B: [ 0 ]
[Submit Button B]
Quantity C: [ 0 ]
[Submit Button C]
Quantity D: [ 0 ]
[Submit Button D]
Each quantity is OK when set to zero, but whenever
Submit Button X is pressed I want my ASP Validator
control to check that Quantity X is greater than
zero.
My problem right now is that asp:RangeValidator
does not seem to provide a way to specify that
the validator is run only when a very particular
button within the form is pressed (as opposed to
whenever any button within the form is pressed).
Could anyone please suggest a solution to this
problem (besides processing POST variables
directly within code and hard coding the
validation in a separate function). Is
there a better way? What is the best
way to tackle this particular problem
in ASP.NET. Yes, I could leave the
input text blank, but that would
violate one of the requirements
of the problem: I want control X
to allow the value zero in the
text box unless the user submits.
Thank you for your replies,
Best Regards,
Neil
|