Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Validation Control

Author  Topic 

urpalshu
Starting Member

21 Posts

Posted - 2007-01-05 : 16:08:25
I have a Compare Validator on my ASPX page Like this

<asp:CompareValidator ID="CompareValidator2"
runat="server"
ControlToCompare="lblDrugs222"
ValueToCompare="Y"
ControlToValidate="txtDEARegistrationNo"
Display="None"
ErrorMessage="Enter A Valid DEA Number">
</asp:CompareValidator>

<asp:TextBox ID="lblDrugs222" runat="server" Text="N" Width="15px"></asp:TextBox>
<asp:textbox id="txtDEARegistrationNo" runat="server" Width="160px" CssClass="bold10">

<asp:button id="btnSubmit1" Text="Submit Your Order" Runat="server" AlternateText="Confirm Order" OnClick="btnSubmit_Click1" BackColor="Yellow" CssClass="bold10color" Width="174px" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"></asp:button>


C# code

my value of lblDrugs222.Text is changed depending on the Item Checked out by the Customer on the CheckOut Page.

protected void btnSubmit_Click1(object sender, EventArgs e)
{
//save data
}

NOTE: IF lblDrugs222.Text == "Y" Then the user has to enter something on txtDEARegistrationNo textbox. He cannot leave the textbox empty
IF lblDrugs222.Text == "N" user can leave the txtDEARegistrationNo textbox empty.

Kindly help me with making the Compare Validator work in my case.
   

- Advertisement -