文本框控件验证 [英] Text Box Control validation

查看:59
本文介绍了文本框控件验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中使用相同的文本框,可能页面显示我想要在每个地方进行相同的验证
任何建议如何维护.

In my projects use same text box may pages show i want same validation in every where
any Suggestion How Maintain.

推荐答案

只需将它们放在用户控件中,然后将相同的用户控件放在任何地方
并获取文本框的文本,请在添加了usercontrol的页面代码中使用此文本
just put them in a usercontrol and put the same usercontrol everywhere
and to get the text of the textbox use this in the page code where added the usercontrol
((TextBox)this.usercontolid.FindControl('the_text_box_id')).Text


您可以将脚本移至单独的js 文件&您可以在每个页面上调用该页面.或者,如果您使用的是验证控件,则可以创建用户控件.
You can move the scripts into separate js file & you can call that every page. Or if you are using Validation controls then you may create user controls.


使用此技术可以解决您的问题

这里txt_my_control是您的< b>控件ID</b>
TextBox box1 =(TextBox)Gridview1.Rows [i] .Cells [2] .FindControl("txt_my_control");
By using this technique you can solve your problem

here txt_my_control is your <b>control Id</b>
TextBox box1 = (TextBox)Gridview1.Rows[i].Cells[2].FindControl("txt_my_control");


这篇关于文本框控件验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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