【问题标题】:Update panel not working when validation group is used使用验证组时更新面板不起作用
【发布时间】:2015-05-26 08:46:01
【问题描述】:

我在更新面板中有以下内容:

<asp:UpdatePanel ID="upAddProduct" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <table border="0" cellpadding="2" cellspacing="2">
                <tr>
                    <td align="left">
                        <asp:Label ID="lblCaption" runat="server"></asp:Label>
                        :
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtValue" runat="server" ValidationGroup="NewValues"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="regInvData" ControlToValidate="txtValue" ErrorMessage="*"
                            runat="server" ValidationGroup="NewValues"></asp:RequiredFieldValidator>
                        <asp:HiddenField runat="server" ID="hdColType" />
                        <asp:HiddenField runat="server" ID="hdnSku" />
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        &nbsp;
                    </td>
                    <td align="left">
                        <asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="btnSubmit_Click"
                            ValidationGroup="NewValues" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
</asp:UpdatePanel>

当我点击上面代码中的提交按钮时,btnSubmit_Click 不会被调用。

当我删除ValidationGroup="NewValues"

函数被调用。

在将其保存在更新面板之前一切正常。

在上述情况下如何使用验证组?

请帮帮我。

【问题讨论】:

  • 我可以在您的代码中看到 javascript 错误。更新面板的结束标签应该是&lt;/asp:UpdatePanel&gt;
  • 触发该按钮。

标签: c# asp.net .net


【解决方案1】:

试试这个,

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td align="left">
<asp:Label ID="lblCaption" runat="server"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtValue" runat="server" ValidationGroup="NewValues"> 
 </asp:TextBox>
<asp:RequiredFieldValidator ID="regInvData" ControlToValidate="txtValue"
ErrorMessage="*"
 runat="server" ValidationGroup="NewValues"></asp:RequiredFieldValidator>
<asp:HiddenField runat="server" ID="hdColType" />
<asp:HiddenField runat="server" ID="hdnSku" />
</td>
</tr>
<tr>
<td align="left">&nbsp;
</td>
<td align="left">
<asp:Button ID="btnSubmit" Text="Submit" runat="server" 
OnClick="btnSubmit_Click"  ValidationGroup="NewValues"
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

对我有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-30
    • 2012-08-30
    • 1970-01-01
    相关资源
    最近更新 更多