jackyrong

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

在asp.net 1.1中,对于验证类控件,在使用时,遇到有的不需要验证的控件时,是十分麻烦的,就是说不可能有选择验证某些控件,而在asp.net 2.0中,新增加了validationgroup属性,可以指定验证某些控件,例子如下:

<html>

<body>

     <form runat=“server”>

          <asp:textbox id=“TextBox1” runat=“server”/>

          <asp:requiredfieldvalidator ValidationGroup=“Group1”

                                                       ErrorText=“Need to Fill in Value!”

                                                       ControlToValidate=“TextBox1”

                                                       runat=“server”/>

 

            <asp:textbox id=“TextBox2” runat=“server”/>

            <asp:requiredfieldvalidator ValidationGroup=“Group2”

                                                         ErrorText=“Need to Fill in Value!”

                                                         ControlToValidate=“TextBox2”

                                                         runat=“server”/>

 

            <asp:button text=“Group1” ValidationGroup=“Group1” runat=“server”/>

            <asp:button text=“Group2” ValidationGroup=“Group2” runat=“server”/>

     </form>

</body>

</html>

posted on 2005-01-15 20:04  jackyrong的世界  阅读(731)  评论(2编辑  收藏  举报