ASP.NET Web Pages 2 Select Value Validation -
i figure must simple , i'm missing obvious. want validate selected value of select input on asp.net web pages 2 form using built in validators doesn't possible far.
for example:
validation.add("my-select", validator.valueequals("some value")); where validator.valueequals compare selected value supplied parameter value "some value". realize do:
if(request["my-select"] != "some value") { validation.addformerror("invalid option selected"); } but don't have error message associated field , appear if i'm rendering validation summary @ top of form.
what missing?
i've cracked code! unfortunately solution outside of scope of built in validation , validators static methods able achieve needed using following in place of using validation class.
if(request["my-select"] != "some value") { modelstate.adderror("my-select", "invalid option selected"); } then check if modelstate valid when checking validation.isvalid():
if(modelstate.isvalid && validation.isvalid()) { // more codes... } it's kind of cool modelstate available seems clunky isn't handled validation , validator classes.
Comments
Post a Comment