Click here to Skip to main content
12,881,367 members (30,109 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
I my project I would like to use the ID of that Compare validator for preparing a report. The following is my code:
<asp:CompareValidator ID="CompareValidator1" runat="server"
            Operator="DataTypeCheck"
            Type="Integer"
            ControlToValidate="TextBox14"
            Text="Text must be an integer." ForeColor="Red"
            style="z-index: 1; left: 90px; top: 22px; position: absolute; " />


When the user enters an integer correctly I would like to use the ID 'Comparevalidator1' in code behind c#, web page.
Posted 31-Jan-13 18:54pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

directly use Id Which is you given


EX: CompareValidator1.Text="Text must be an integer"

same way you can do for other properties,
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

write these line in page load event.....

CompareValidator1.Text = "Compare unsuccessfull";
            CompareValidator1.ControlToValidate = "TextBox1";
            CompareValidator1.ControlToCompare = "TextBox2";



where CompareValidator1 is compare validater id, TextBox1 is id of control to which you are assigning validation and TextBox2 is id of control to which you are comparing..
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170422.1 | Last Updated 1 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100