Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Validation of RadioButtonList

Thread Tools

Validation of RadioButtonList

Posts: n/a
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.

Reply With Quote
Posts: n/a
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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
validation on items of radiobuttonlist in jsp rishi pariahr via .NET 247 ASP .Net 2 04-05-2005 12:34 PM
ASP.NET Web Forms Validation Controls are Server-Side or Client-Side Validation? Matt ASP .Net 14 01-30-2004 09:15 AM
Web form validation vs object validation Colin Basterfield ASP .Net 1 11-29-2003 12:10 AM
validation summary doesnt display when there's client-side validation Libs ASP .Net 0 06-25-2003 03:05 PM
Re: only custom validation control does server side validation? Colin Mackay ASP .Net 0 06-25-2003 07:54 AM