有两个的UpdatePanel和验证问题 [英] Problem with two UpdatePanels and Validators

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

问题描述

在以下code ...

In the following code...

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
        <cc1:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
            Display="Dynamic" ErrorMessage="This field is required">
            *</cc1:RequiredFieldValidator>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

<asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
        <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

为什么的 UpdatePanel2 是受含量的RequiredFieldValidator 中存在的 UpdatePanel1

Why the content of UpdatePanel2 is affected by the RequiredFieldValidatorwhich exists in the UpdatePanel1 !!!

他们分裂和的UpdateMode 为他们设置为条件

They're splitted and the UpdateMode for them is set to Conditional !!!

任何帮助!

推荐答案

使用的ValidationGroup属性类似以下,

Use the ValidationGroup property like the following,

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" ValidationGroup="UpdatePanel1"></asp:TextBox>
        <cc1:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" controltovalidate="TextBox1"
            display="Dynamic" errormessage="This field is required" ValidationGroup="UpdatePanel1">               *</cc1:requiredfieldvalidator>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" ValidationGroup="UpdatePanel1" />
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
        <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
</asp:UpdatePanel>

这篇关于有两个的UpdatePanel和验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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