473,722 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4375
RequiredFieldVa lidator 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****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remo ve.terra.com.br > wrote in message
news:%2******** ********@TK2MSF TNGP12.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.in fo> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
RequiredFieldVa lidator 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****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remo ve.terra.com.br > wrote in message
news:%2******** ********@TK2MSF TNGP12.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*******@remo ve.terra.com.br > wrote in message
news:%2******** ********@TK2MSF TNGP12.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
RequiredFieldVa lidator without changing InitialValue.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remo ve.terra.com.br > wrote in message
news:Ou******** ******@TK2MSFTN GP15.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.in fo> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
RequiredFieldVa lidator 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****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fernando Lopes" <fe*******@remo ve.terra.com.br > wrote in message
news:%2******** ********@TK2MSF TNGP12.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
7870
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 allso subclassed the window and do see all kinds of WS_??? messages coming by. But now I'm stuck :-\ I've got *no* idea what to do next, and all my searching on the web leads me
0
454
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 inthe control are valid. This is easy using: if (Page.IsPostBack) { Page.Validate(); if (Page.IsValid) {
8
2883
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 this listbox but I can't for the life of me figure out how to draw the control inside ListBox... I get as far as: private void lbImageList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
8
5399
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 IsValid then exit sub end if
3
5961
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 validators, so I have a button on the form and the "causes validation" property is set to true. I have overridden the "Validate()" like so
4
2597
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 figured since all the panel data is still being sent through the postbacks, instead of using Sessions, or HttpContext, I could just take the values from the textboxes. This all works fine, except for security. I realized that I could inject...
1
3422
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 foreach (Product p in manager.Products) { ASP.MasterDetailDropDown productMasterDetail; productMasterDetail = (ASP.MasterDetailDropDown)LoadControl("~/controls/MasterDetailDropDown.ascx"); ...
0
879
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 TextBox) to do this validation. I have added properties to my UserControl that make the properties necessary to do validation available, so everything I need is available once i have access to the UserControl. However, I am having trouble doing...
6
8356
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) correctly. In other words the Items property of the ListBox is populated from the ViewState after the postback. However if I put this ListBox inside a UserControl, expose the Items list, and populate it with the data in the same manner (in the page...
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.