Validate a ListBox using validators inside a usercontrol

Discussion in 'ASP .Net' started by Fernando Lopes, Nov 17, 2004.

  1. Hi.
    I have a page with a usercontrol.
    In this UC, I have two ListBoxes and two buttons. When i click in one
    button, i get the selected item in the listbox.
    How can i validate, using validators, if the selected listbox has a selected
    item?

    Thanks.

    Fernando
     
    Fernando Lopes, Nov 17, 2004
    #1
    1. Advertising

  2. Fernando Lopes

    Peter Blum Guest

    RequiredFieldValidator does it. If you "unselected" state is actually the
    first item shown, set its InitialValue property to the value you assigned to
    that "unselected" item.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Fernando Lopes" <> wrote in message
    news:%...
    > Hi.
    > I have a page with a usercontrol.
    > In this UC, I have two ListBoxes and two buttons. When i click in one
    > button, i get the selected item in the listbox.
    > How can i validate, using validators, if the selected listbox has a
    > selected item?
    >
    > Thanks.
    >
    > Fernando
    >
     
    Peter Blum, Nov 17, 2004
    #2
    1. Advertising

  3. Thanks Peter.
    But how can i do that? I say this because my "unselected" value is a blank
    ListItem.

    Thanks again.
    Fernando

    "Peter Blum" <> wrote in message
    news:%...
    > RequiredFieldValidator does it. If you "unselected" state is actually the
    > first item shown, set its InitialValue property to the value you assigned
    > to that "unselected" item.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Fernando Lopes" <> wrote in message
    > news:%...
    >> Hi.
    >> I have a page with a usercontrol.
    >> In this UC, I have two ListBoxes and two buttons. When i click in one
    >> button, i get the selected item in the listbox.
    >> How can i validate, using validators, if the selected listbox has a
    >> selected item?
    >>
    >> Thanks.
    >>
    >> Fernando
    >>

    >
    >
     
    Fernando Lopes, Nov 17, 2004
    #3
  4. In true, my listbox doesn't have a "unselected" item.

    "Fernando Lopes" <> wrote in message
    news:%...
    > Hi.
    > I have a page with a usercontrol.
    > In this UC, I have two ListBoxes and two buttons. When i click in one
    > button, i get the selected item in the listbox.
    > How can i validate, using validators, if the selected listbox has a
    > selected item?
    >
    > Thanks.
    >
    > Fernando
    >
     
    Fernando Lopes, Nov 17, 2004
    #4
  5. Fernando Lopes

    Peter Blum Guest

    When there is no selection, the validator will retrieve to a value of ""
    from the listbox. Your InitialValue property is already "". So just use the
    RequiredFieldValidator without changing InitialValue.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Fernando Lopes" <> wrote in message
    news:Ou$Vv$...
    > Thanks Peter.
    > But how can i do that? I say this because my "unselected" value is a blank
    > ListItem.
    >
    > Thanks again.
    > Fernando
    >
    > "Peter Blum" <> wrote in message
    > news:%...
    >> RequiredFieldValidator does it. If you "unselected" state is actually the
    >> first item shown, set its InitialValue property to the value you assigned
    >> to that "unselected" item.
    >>
    >> --- Peter Blum
    >> www.PeterBlum.com
    >> Email:
    >> Creator of "Professional Validation And More" at
    >> http://www.peterblum.com/vam/home.aspx
    >>
    >> "Fernando Lopes" <> wrote in message
    >> news:%...
    >>> Hi.
    >>> I have a page with a usercontrol.
    >>> In this UC, I have two ListBoxes and two buttons. When i click in one
    >>> button, i get the selected item in the listbox.
    >>> How can i validate, using validators, if the selected listbox has a
    >>> selected item?
    >>>
    >>> Thanks.
    >>>
    >>> Fernando
    >>>

    >>
    >>

    >
    >
     
    Peter Blum, Nov 18, 2004
    #5
    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. Rajesh Tiwari

    Can we use a usercontrol inside a usercontrol

    Rajesh Tiwari, Aug 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    438
    Rajesh Tiwari
    Aug 12, 2003
  2. Ratman
    Replies:
    0
    Views:
    692
    Ratman
    Sep 14, 2004
  3. nail
    Replies:
    0
    Views:
    1,568
  4. Nathan Sokalski

    Using Validators to validate UserControls

    Nathan Sokalski, Sep 5, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    301
    Nathan Sokalski
    Sep 5, 2008
  5. Nathan Sokalski

    Using Validators to validate UserControls

    Nathan Sokalski, Sep 5, 2008, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    126
    Nathan Sokalski
    Sep 5, 2008
Loading...

Share This Page