By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,501 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,501 IT Pros & Developers. It's quick & easy.

Validate a ListBox using validators inside a usercontrol

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remove.terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #2

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

Thanks again.
Fernando

"Peter Blum" <PL****@Blum.info> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remove.terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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


Nov 18 '05 #3

P: n/a
In true, my listbox doesn't have a "unselected" item.

"Fernando Lopes" <fe*******@remove.terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #4

P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remove.terra.com.br> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
Thanks Peter.
But how can i do that? I say this because my "unselected" value is a blank
ListItem.

Thanks again.
Fernando

"Peter Blum" <PL****@Blum.info> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remove.terra.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.