updatepanel内的按钮会导致不需要的完整回发

时间:2009-08-05 12:06:35

标签: ajax updatepanel ajaxcontroltoolkit

我在登录页面上丢失了密码恢复功能,而我正在使用ModalPopUpExtender,一个Panel和一个UpdatePanel内的两个。但不知何故,当点击“btnOkPassRequest”完全回发时。人们对其他控件有类似的问题,一些UpdatePanel显然没有封装。但绝不使用Button。我错过了什么?

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>  
    <asp:HyperLink ID="HyperLink2" runat="server">HyperLink</asp:HyperLink>
    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"TargetControlID="HyperLink2" BackgroundCssClass="ModalPopupBG" PopupControlID="pnlPopupPass" CancelControlID="btnCancelPassRequest" OkControlID="Button1"></cc1:ModalPopupExtender>
    <asp:Panel ID="pnlPopupPass" runat="server" CssClass="ModalPopup">   
      <div class="ModalHeader">Password recovery</div>
      <div class="ModalBody">
        <p>Please, enter username.....</p>
        <table>
        <tr>
                <td>Username</td>
                <td><asp:TextBox ID="tbModalUserName" runat="server" class="textbox"></asp:TextBox></td>            
            </tr>
          </table>
        <table>
            <tr>
          <td></td>
            <td><asp:Button ID="btnOKPassRequest" runat="server" Text="Request new password" CssClass="button-wide" onclick="btnOKPassRequest_Click" PostBackUrl="~/Login.aspx" /></td>
            <td><asp:Button ID="btnCancelPassRequest" runat="server" Text="Cancel" CssClass="button-wide"/></td>
            </tr>
        </table>        
      </div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </asp:Panel>
</ContentTemplate>
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnOKPassRequest" EventName="btnOKPassRequest_Click" />
</Triggers>

3 个答案:

答案 0 :(得分:2)

我认为EventName应该只是“点击”而不是触发器中的“btnOKPassRequest_Click”

答案 1 :(得分:1)

你确定应该在那里吗?

 PostBackUrl="~/Login.aspx"

如果没有这个,它对我来说很好。

我也删除了触发器,但是如果你需要触发器,那么EventName应该是Click。

<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:HyperLink ID="HyperLink2" runat="server">HyperLink</asp:HyperLink>
            <asp:Panel ID="pnlPopupPass" runat="server" CssClass="ModalPopup">
                <div class="ModalHeader">
                    Password recovery</div>
                <div class="ModalBody">
                    <p>
                        Please, enter username.....</p>
                    <table>
                        <tr>
                            <td>
                                Username
                            </td>
                            <td>
                                <asp:TextBox ID="tbModalUserName" runat="server" class="textbox"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <asp:Button ID="btnOKPassRequest" runat="server" Text="Request new password" CssClass="button-wide"
                                    OnClick="btnOKPassRequest_Click" />
                            </td>
                            <td>
                                <asp:Button ID="btnCancelPassRequest" runat="server" Text="Cancel" CssClass="button-wide" />
                            </td>
                        </tr>
                    </table>
                </div>
                <asp:Button ID="Button1" runat="server" Text="Button" />
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>

答案 2 :(得分:0)

实际上,当我切换到ajax控件工具包v1而不是使用3.5时,问题就消失了,这真的令人困惑