如何在asp.net中验证文本框 [英] how to validate text boxws in asp.net

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

问题描述

嗨.
这是洛克什
我的问题是我有2个带有2个按钮的文本框,但textbox1应该在同一页面中对button1进行验证,而textbox2应该对在同一页面中的button2进行验证

帮助我

hi.
this is lokesh
my problem is i have 2 textboxes with 2 buttons but textbox1 should validate to button1 and textbox2 should validate to button2 in same page please

help me

推荐答案

设置Textbox1 Button1
validationgroup=a属性 并对Textbox2 Button2做相同的设置validationgroup=b.


记住 !!两个按钮的CausesValidation 必须为true.(Button1 Button2)


如果您有答案,请解决.


谢谢
Ashish
set validationgroup=a property of Textbox1 and Button1
and do the same set validationgroup=b for Textbox2 and Button2.


Remember !! CausesValidation must be true for both buttons.(Button1 and Button2)


Make it solution if you got your answer.


Thanks
Ashish


从MSDN中阅读以下文章,并使用validationGroup属性


http://msdn.microsoft.com/en-us/library/ms227424.aspx [ ^ ]
Read below article from MSDN and use validationGroup property


http://msdn.microsoft.com/en-us/library/ms227424.aspx[^]


我认为这会对您有所帮助,

i think this will help you,

<asp:textbox id="TextBox1" runat="server"></asp:textbox>
        <asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" errormessage="1st one" validationgroup="1st" controltovalidate="TextBox1">
        </asp:requiredfieldvalidator>
        <asp:button id="Button1" runat="server" text="Button" validationgroup="1st" causesvalidation="true" /><br />

        <asp:textbox id="TextBox2" runat="server"></asp:textbox>
        <asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" errormessage="2nd one" validationgroup="2nd" controltovalidate="TextBox2">
        </asp:requiredfieldvalidator>
        <asp:button id="Button2" runat="server" text="Button" validationgroup="2nd" causesvalidation="true" />


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

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