aspx thread: CompareValidator Controls - validating against dropdown control
Message #1 by "Jacques Leclerc" <jleclerc2@h...> on Thu, 9 Nov 2000 12:23:43 -0500
|
|
All of the information and examples that I can find have the
CompareValidator control associated with a Textbox. Can the validator
controls be used against a dropdown? If it can, how do you specify if the
compare is against the value or text property of the dropdown?
Any information will be appreciated.
Jacques
Message #2 by "Fredrik Normen" <fredrik.normen@e...> on Sat, 11 Nov 2000 17:02:58 -0000
|
|
Hi,
Here you have an example.
To test it write SE or EN or US in the Country code textbox.
After this choose a country from the ListBox.
An Error will be displayed if you not coose the right one.
<%@ PAGE LANGUAGE="VB"%>
<HTML>
<BODY>
<FORM RUNAT="Server">
Country code: ( SE or EN or US ) <BR>
<INPUT ID="FirstName" RUNAT="Server"><BR>
Country:<BR>
<ASP:DropDownList id="Customers" RUNAT="Server">
<ASP:ListItem VALUE="SE">Sweden</ASP:ListItem>
<ASP:ListItem VALUE="EN">ENgland</ASP:ListItem>
<ASP:ListItem VALUE="US">USA</ASP:ListItem>
</ASP:DropDownList>
<asp:CompareValidator id="CompareFieldValidator1" runat="server"
ForeColor="Red"
ControlToValidate="Customers"
ControlToCompare="FirstName"
Type="String"
Operator="Equal"
ErrorMessage="Error"/>
<INPUT TYPE="Submit" RUNAT="Server">
</FORM>
</BODY>
</HTML>
I hope this will help you.
/Fredrik Normen
|