473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Validate a ListBox using validators inside a usercontrol

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
4 4358
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
0
by: Christopher H. Laco | last post by:
I have a web user control that, like most, has a couple of fields with their corrisponding validators. What I want to do is perform some other lookup inside of the control if all of the validators...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
8
by: tshad | last post by:
I get the following message from one of my buttons where I have CauseValidation=false. Page.IsValid cannot be called before validation has taken place In my routine I need to do: if Not...
3
by: Martin | last post by:
Hi, I am implemeting a form in asp.net. The form is quite large and the validation is reasonably complex, so I have decieded to implement my own validation rather than use any custon...
4
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I...
1
by: stimul8d | last post by:
okay; ASP. I have i listbox inside a user control which is dynamically created on page_init. I check for postback and only populate the datasource if it's false. regardless, i do this ...
0
by: Nathan Sokalski | last post by:
I have a UserControl that contains Controls I want to validate. I am attempting to write a class that inherits BaseValidator (which I have done many times before for the standard controls such as...
6
by: kucheravy | last post by:
Hi, everybody. I have this problem. When I put a <asp:ListBox on a web page and populate the data in the page Page_Load event the ViewState for the control is saved and loaded (after postback)...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.