0

我一直对模态弹出窗口有这个奇怪的问题。出于某种原因,当我选择一个下拉项时,我的更新按钮不会触发点击事件。但随后我将下拉菜单保留为默认值,更新按钮工作得很好。

这是我的 aspx 页面代码

<asp:Button ID="Button1" CssClass="hide" runat="server" Text="Button" />

<ajaxToolkit:ModalPopupExtender runat="server" ID="cfPopUp" PopupControlID="Panel4"
    TargetControlID="Button1" OkControlID="cfUpdateBtn" CancelControlID="cfCancelBtn" />
<asp:Panel ID="Panel4" runat="server" CssClass="modalPopup">
    <asp:UpdatePanel ID="UpdatePanel2" runat="Server">
        <ContentTemplate>
            <asp:Panel ID="Panel13" CssClass="" runat="server">
                <asp:Panel ID="Panel14" CssClass="" runat="server">
                    <div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
                        <asp:Label ID="Label25" Width="200px" runat="server" Text="Health and Safety Net" /><div
                            class="seperator">
                        </div>
                        <table class="style143">
                            <tr>
                                <td class="style185">
                                    <asp:Label ID="cfCategorylbl" runat="server" Text="Category:"></asp:Label>:
                                </td>
                                <td>
                                    <asp:DropDownList ID="cbFactors_Categories" runat="server" Width="350px" Font-Names="Tahoma"
                                        Font-Size="Small" ForeColor="DimGray" Height="24px" CssClass="style75">
                                    </asp:DropDownList>
                                    <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="cbFactors_Categories"
                                        Category="categories" ServiceMethod="getCategory" ServicePath="~/2012/IrSubmitWebService.asmx"
                                        PromptText="Select Category" />
                                </td>
                                <td align="center" rowspan="3" valign="top">
                                    <asp:Label ID="lblFactor_ID" runat="server" Font-Names="Tahoma" Font-Size="Small"
                                        ForeColor="DimGray" Style="font-style: italic" TabIndex="56"></asp:Label>
                                    <cc1:DynamicPopulateExtender ID="lblFactor_ID_DynamicPopulateExtender" runat="server"
                                        Enabled="True" TargetControlID="lblFactor_ID" BehaviorID="dp1" ServiceMethod="getFactorID"
                                        ServicePath="~/2012/IrSubmitWebService.asmx">
                                    </cc1:DynamicPopulateExtender>
                                    <hr class="style157" />
                                    <asp:Label ID="cfID" runat="server" Font-Names="Tahoma" Font-Size="Small" ForeColor="DimGray"
                                        Style="font-style: italic" Width="400px" TabIndex="57"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td class="style185">
                                    <asp:Label ID="cfTypeslbl" runat="server" Text="Type:"></asp:Label>
                                </td>
                                <td>
                                    <asp:DropDownList ID="cbFactors_Types" runat="server" ForeColor="DimGray" Height="24px"
                                        TabIndex="54" Width="350px" Font-Names="Tahoma" Font-Size="Small" CssClass="style75">
                                    </asp:DropDownList>
                                    <cc1:CascadingDropDown ID="cbFactors_Types_CascadingDropDown" runat="server"
                                        TargetControlID="cbFactors_Types" ParentControlID="cbFactors_Categories" Category="type"
                                        ServiceMethod="getTypeofAction" ServicePath="~/2012/IrSubmitWebService.asmx"
                                        PromptText="Select Type">
                                    </cc1:CascadingDropDown>
                                </td>
                            </tr>
                            <tr>
                                <td class="style185">
                                    <asp:Label ID="cfFactorslbl" runat="server" Text="Factor:"></asp:Label>
                                </td>
                                <td>
                                    <asp:DropDownList ID="cbFactors_Factors" runat="server" ForeColor="DimGray" Height="24px"
                                        TabIndex="55" Width="350px" Font-Names="tahoma" Font-Size="Small" CssClass="style75">
                                    </asp:DropDownList>
                                    <cc1:CascadingDropDown ID="cbFactors_Factors_CascadingDropDown" runat="server"
                                        TargetControlID="cbFactors_Factors" ParentControlID="cbFactors_Types" Category="category"
                                        ServiceMethod="getFactor" ServicePath="~/2012/IrSubmitWebService.asmx" PromptText="Select Factor">
                                    </cc1:CascadingDropDown>
                                </td>
                            </tr>
                            <tr>
                                <td class="style185">
                                    <asp:Label Text="Justification:" ID="cfJustificationlbl" runat="server"></asp:Label>
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="29px"
                                        Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
                                        ToolTip="Provide a justification for this factor." Width="775px" Font-Names="Tahoma"
                                        Font-Size="Small"></asp:TextBox>
                                   </td>
                            </tr>
                        </table>
                        <br />
                        <div style="text-align: center">
                            <asp:Button CausesValidation="false" ID="cfUpdateBtn" runat="server"
                                Text="Update" CssClass="button" /><span style="margin-left: 10px"><asp:Button CausesValidation="false"
                                    ID="cfCancelBtn" runat="server" Text="Cancel" CssClass="button" /></span></div>
                    </div>
                </asp:Panel>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>

以及我的更新代码(它只是关闭了弹出窗口)

Protected Sub cfUpdateBtn_Click(sender As Object, e As EventArgs) Handles cfUpdateBtn.Click
    cfPopUp.Hide()
End Sub

对于我的一生,我无法弄清楚为什么当下拉列表不是默认值时更新按钮不起作用。

谢谢你们的帮助

4

2 回答 2

0

可能的原因可能是您将下拉列表与 Web 服务绑定。每当您单击下拉列表中的某个项目时,可能会调用 Web 服务。如果调用 web 服务,那么您的页面可能会再次加载吗?我不知道它不起作用的确切原因。您必须检查调用服务时发生的服务行为。

于 2012-07-09T18:29:56.920 回答
0

我基本上像这样重建了我的模态弹出窗口和更新面板

<asp:Panel ID="pnlEditPopup" runat="server" CssClass="modalPopup">
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>

        <asp:Panel ID="pnlEditPopupContent" runat="server">
            <div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
            <table cellpadding="0" cellspacing="4" border="0">
            <tr>
                <td class="name">Category:</td>
                <td class="value">
                    <asp:DropDownList id="ddCat" runat="server">
                        <asp:listitem value="">No Selection</asp:listitem>
                        <asp:listitem value="Action">Action</asp:listitem>
                        <asp:listitem value="Worksite">Worksite</asp:listitem>
                        <asp:listitem value="Human Factors">Human Factors</asp:listitem>
                        <asp:listitem value="System Factors">System Factors</asp:listitem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="name">Type:</td>
                <td class="value">
                    <asp:DropDownList id="ddType" runat="server" />
                    <ajaxToolkit:CascadingDropDown ID="ccType" runat="server"
                        TargetControlID="ddType"
                        ParentControlID="ddCat"
                        PromptText="No Selection"
                        LoadingText="Please Wait..."
                        ServicePath="~/2012/IrSubmitWebService.asmx"
                        ServiceMethod="getTypeofAction"
                        Category="Other"
                    />
                </td>
            </tr>
             <tr>
                <td class="name">Factor:</td>
                <td class="value">
                    <asp:DropDownList id="ddfactor" runat="server" />
                    <ajaxToolkit:CascadingDropDown ID="ccFactor" runat="server"
                        TargetControlID="ddfactor"
                        ParentControlID="ddType"
                        PromptText="No Selection"
                        LoadingText="Please Wait..."
                        ServicePath="~/2012/IrSubmitWebService.asmx"
                        ServiceMethod="getFactor"
                        Category="Other"
                    />
                </td>
            </tr>
            <tr>
                <td>
                    Justification:
                    <asp:Label ID="factorID" runat="server" Visible="false"></asp:Label>
                </td>

                <td>
                    <asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="100px"
                    Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
                    ToolTip="Provide a justification for this factor." Width="300px" Font-Names="Tahoma"
                    Font-Size="Small"></asp:TextBox>
                </td>
            </tr>
             <tr>
                <td>
                    Factor ID<br />
                    and Description:             
                </td>
                <td>
                    <asp:Label ID="factor_id_Desc" runat="server" Width="300px" Font-Names="Tahoma" Font-Size="Small"
                        ForeColor="DimGray" TabIndex="56"></asp:Label>
                    <cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server"
                        Enabled="True" TargetControlID="factor_id_Desc" BehaviorID="dp1" ServiceMethod="getFactorID"
                        ServicePath="~/2012/IrSubmitWebService.asmx">
                    </cc1:DynamicPopulateExtender>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Button ID="btnOkEditPopup" runat="server" Text="Ok" CssClass="button"/>
                    <span style="margin-left:10px"><asp:button id="btnCancelEditPopup" runat="server" text="Cancel" CssClass="button"/></span>
                </td>
            </tr>

            </table>
            </div>
        </asp:Panel>

    </ContentTemplate>
    </asp:UpdatePanel>
    </asp:Panel>

    <ajaxToolkit:ModalPopupExtender ID="mpeEdit" runat="server"
        TargetControlID="btnOpenEditPopup"
        PopupControlID="pnlEditPopup"
        />

修复了我的问题。当我问这个问题时,我仍然不知道为什么它不起作用,但我能够解决它。感谢所有为我调查的人。

于 2012-07-10T17:42:36.693 回答