Validation of RadioButtonList

Discussion in 'ASP .Net Web Controls' started by cpnet, Dec 23, 2006.

  1. cpnet

    cpnet Guest

    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.
    cpnet, Dec 23, 2006
    #1
    1. Advertising

  2. cpnet

    cpnet Guest

    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.
    cpnet, Dec 24, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Mackay
    Replies:
    0
    Views:
    2,677
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,482
  3. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    420
    Tommy
    Nov 29, 2003
  4. Matt
    Replies:
    14
    Views:
    4,069
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  5. rishi pariahr via .NET 247

    validation on items of radiobuttonlist in jsp

    rishi pariahr via .NET 247, Apr 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    563
Loading...

Share This Page