对 ASP.Net 中 GridView 中的 TextBox 的 JavaScript 验证 [英] JavaScript Validation to TextBox in a GridView in ASP.Net

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

问题描述

我有一个 GridView,其中模板字段中有四个文本框.我在 GridView 下方有一个按钮.

I have a GridView in Which I have four TextBoxes in the Template Field. I have one Button below the GridView.

如何验证 GridView 中的 TextBoxes,当按钮被点击时?

How to validate the TextBoxes in the GridView, When the Button Clicked?

推荐答案

使用RequiredFieldValidator并设置ValidationGroup="gridview",查看下面的例子

use RequiredFieldValidator and set ValidationGroup="gridview", check below example

   <asp:TemplateField HeaderText="">
          <ItemTemplate>
              <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
               <asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="TextBox3" ValidationGroup="gridview" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
          </ItemTemplate>
            </asp:TemplateField>
          <asp:TemplateField HeaderText="">
                <ItemTemplate>
                    <asp:Button ID="Button2" runat="server" Text="Button" ValidationGroup="gridview" CausesValidation="true" />
                </ItemTemplate>
            </asp:TemplateField>

这篇关于对 ASP.Net 中 GridView 中的 TextBox 的 JavaScript 验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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