[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Mike Harris

1/7/2003 10:50:00 PM

Does anyone know how to require a user to make at least one selection from a
group of three different drop down lists? I need to be able to group them
together and then insert a validator that looks at the three drop downs as a
unit.

Thanks,

Mike Harris


1 Answer

(Bassel Tabbara [MSFT])

1/8/2003 5:49:00 PM

0

Hello Mike,
I included a sample that provides whether a user has been made a selection
of one of the three dropdownlist.

DropDownListValidator.aspx
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="DropDownListValidator.aspx.vb"
Inherits="DifferentTests.DropDownListValidator"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>DropDownListValidator</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5...
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 17px;
POSITION: absolute; TOP: 12px" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList id="DropDownList3" style="Z-INDEX: 103; LEFT: 14px;
POSITION: absolute; TOP: 102px" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="7">Seven</asp:ListItem>
<asp:ListItem Value="8">Eight</asp:ListItem>
<asp:ListItem Value="9">Nine</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList id="DropDownList2" style="Z-INDEX: 102; LEFT: 21px;
POSITION: absolute; TOP: 56px" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="4">Four</asp:ListItem>
<asp:ListItem Value="5">Five</asp:ListItem>
<asp:ListItem Value="6">Six</asp:ListItem>
</asp:DropDownList>
<asp:Button id="Button1" style="Z-INDEX: 107; LEFT: 150px; POSITION:
absolute; TOP: 175px" runat="server" Text="Submit"></asp:Button>
</form>
</body>
</HTML>

DropDownListValidator.aspx.vb
Public Class DropDownListValidator
Inherits System.Web.UI.Page
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents DropDownList2 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents DropDownList3 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If (DropDownList1.SelectedItem.Text = "" And
DropDownList2.SelectedItem.Text = "" And _
DropDownList2.SelectedItem.Text = "") Then
Response.Write("You must choose at least one choice from one of
the three DropDown")
End If
End Sub

I hope this is helpful.

Thanks,

Bassel Tabbara
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
| Reply-To: "Mike Harris" <mikeh@southernmills.com>
| From: "Mike Harris" <mikeh@southernmills.com>
| Subject: DropDown List Validation
| Date: Tue, 7 Jan 2003 16:50:09 -0500
| Lines: 10
| Organization: Southern Mills
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <eszIzbptCHA.2620@TK2MSFTNGP11>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: 205.167.158.10
| Path: cpmsftngxa09!TK2MSFTNGP08!TK2MSFTNGP11
| Xref: cpmsftngxa09
microsoft.public.dotnet.framework.aspnet.webcontrols:8298
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Does anyone know how to require a user to make at least one selection
from a
| group of three different drop down lists? I need to be able to group them
| together and then insert a validator that looks at the three drop downs
as a
| unit.
|
| Thanks,
|
| Mike Harris
|
|
|