如何在c#web后面的代码中使用比较验证器ID [英] How to use the compare validator ID in code behind c# web

查看:70
本文介绍了如何在c#web后面的代码中使用比较验证器ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目我想使用Compare验证器的ID来准备报告。以下是我的代码:

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; " />





当用户正确输入一个整数时,我会喜欢e在c#,web页面后面的代码中使用IDComparevalidator1。



When the user enters an integer correctly I would like to use the ID ''Comparevalidator1'' in code behind c#, web page.

推荐答案

直接使用Id你给的是什么





EX:CompareValidator1.Text =文字必须是整数



你可以这样做对于其他属性,
directly use Id Which is you given


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

same way you can do for other properties,


在页面加载事件中写下这些行.....



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

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







其中 CompareValidator1 是比较验证器ID, TextBox1 是您的控件ID分配验证和 TextBox2 是您要比较的控件的ID ..




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..


这篇关于如何在c#web后面的代码中使用比较验证器ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆