Validation of RadioButtonList
I've added a RadioButtonList (with 2 choices, neither selected by default),
and a RequiredFieldValidator to a WebForm. Basically, I want a red asterisk
to appear beside the RadioButtonList until the user selects on of the
choices. I'd like this validation to fire on the client side. I've set
RequiredFieldValidator.ControlToValidate to my RadioButtonList. I've set
RadioButtonList.CausesValidation to "true" on the RadioButtonList. Still,
when the page is first rendered, I don't see the validation control display
my red asterisk. I added a button that does nothing but cause the form to
postback. Causing a postback with this button still doesn't make the
RequiredFieldValidator.Text show up. I must be doing something wrong, but I
can't figure out what.
Re: Validation of RadioButtonList
I was doing 2 things wrong:
1) I was setting the RequiredFieldValidator.InitialValue property (not
knowing what it does). I shouldn't have been setting this.
2) On Page_Load I should have been calling Page.Validate() if I wasn't
doing a post back, to force validation the first time the page is rendered.
I wasn't doing this.
Once I fixed these 2 things, it worked fine.
|All times are GMT. The time now is 11:56 AM.|
SEO by vBSEO ©2010, Crawlability, Inc.