0

我有一个下拉列表的RequiredFieldValidator。两者都在 UpdatePanel 内。单击提交按钮时,它不会验证下拉列表中的用户选择。请指导我错过了什么。

   <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="divFilter">
    <asp:UpdatePanel ID="uplMain" runat="server">
        <ContentTemplate>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server">
                <table>
                    <tr>
                        <td valign="top">
                            <table>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="chkBusiness" runat="server" Text="Business Division" CssClass="chkbox" />
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlBusiness" runat="server" AppendDataBoundItems="true" AutoPostBack="true"
                                            CausesValidation="True" OnSelectedIndexChanged="ddlBusiness_SelectedIndexChanged"
                                            ValidationGroup="grpSubmit" Width="350px">
                                            <asp:ListItem Selected="True" Value="-1">--- SELECT ---</asp:ListItem>
                                        </asp:DropDownList>
                                        <asp:RequiredFieldValidator ID="rfvBusiness" runat="server" ControlToValidate="ddlBusiness"
                                            ToolTip="Please select a Business." ErrorMessage="*" CssClass="required" Display="Dynamic"
                                            ValidationGroup="grpSubmit" Enabled="false">
                                        </asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </asp:PlaceHolder>
            <hr size="1" />
            <div style="text-align: center">
                <table style="width: 10%">
                    <tr>
                        <td>
                            <asp:Button ID="btnHome" runat="server" Text="Home" OnClick="btnHome_Click" CssClass="btn" />
                        </td>
                        <td>
                            <asp:Button ID="btnSubmitReport" runat="server" Text="Submit" OnClick="btnSubmitReport_Click"
                                ValidationGroup="grpSubmit" CssClass="btn" />
                        </td>
                    </tr>
                </table>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>
4

1 回答 1

0

尝试将RequiredFieldValidator元素中的Enabled属性设置为“True”。

于 2017-04-11T00:32:31.483 回答