简体   繁体   English

使用modelpopupextender时未触发ASP.NET按钮事件

[英]ASP.NET button event not firing when using modelpopupextender

I have one Panel that is linked to a ModelPopupExtenderand there is a button inside the first panel. 我有一个链接到ModelPopupExtender的面板,并且第一个面板内有一个按钮。 When I click the first panel's button I want it to execute the event and inside this event I want to pop up the second Panel which is also linked to a ModelPopupExtender, but when I click the first Panel's button the event does not trigger. 当我单击第一个面板的按钮时,我希望它执行该事件,在此事件中,我想弹出第二个面板,该面板也链接到ModelPopupExtender,但是当我单击第一个面板的按钮时,该事件不会触发。

Asp Code : 邮递区号:

<input type="hidden" runat="server" id="hdnEditBank1" />
<asp:Panel runat="server" ID="pnl1" CssClass="Modal450h450w" Height="300px">
    <table id="tblEditBank1" runat="server">
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="right" colspan="2"><img runat="server" id="imgExitEdit1"  src="../images/Exit_cross.png" /></td>
        </tr>
        <tr>
            <td colspan="3">Name : </td>
            <td colspan="2"><telerik:RadTextBox ID="txt1" runat="server" CssClass="largebox"></telerik:RadTextBox></td>
        </tr>

        <tr>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
        <tr>                            
            <td colspan="4">
                <asp:Button runat="server" ID="btnClose" Text="Close" OnClick="btnAdd_Close_Click" />                    
            </td>
            <td align="right">
                <asp:Button runat="server" ID="btnNext" Text="Next" OnClick="btnEdit_Next_Click" />
            </td>
        </tr>
    </table>
</asp:Panel>

<!-- second panel -->
<asp:ModalPopupExtender ID="ModalPopupExtender6" runat="server" TargetControlID="btnNext" OkControlID="imgExitEdit1"
    PopupControlID="pnl2" BackgroundCssClass="LoadingBackground" >
</asp:ModalPopupExtender>

<input type="hidden" runat="server" id="Hidden1" />
<asp:Panel runat="server" ID="pnl2" CssClass="Modal450h450w" Height="300px">
    <table id="Table1" runat="server">
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td align="right" colspan="2"><img runat="server" id="img1"  src="../images/Exit_cross.png" /></td>
        </tr>
        <tr>
            <td colspan="3">Some Label : </td>
            <td colspan="3"><telerik:RadTextBox ID="txtSomeText" runat="server" CssClass="largebox"></telerik:RadTextBox></td>
        </tr>        
        <tr>                            
            <td colspan="4">
                <asp:Button runat="server" ID="btnIbanClose" Text="Close" OnClick="btnAdd_Close_Click" />                    
            </td>
            <td align="right">
                <asp:Button runat="server" ID="btnIbanReview" Text="Next" OnClick="btnEdit_Next_Click" />
            </td>
        </tr>
    </table>
</asp:Panel>

The code behind : 后面的代码:

protected void btnEdit_Next_Click(object sender, EventArgs e)
{          
        ModalPopupExtender6.Show();
}

I am thinking it's about the AutoPostBack but I am not sure how to resolve this 我认为这与AutoPostBack有关,但我不确定如何解决此问题

I have found the solution to this if anybody is interested. 如果有人感兴趣,我已经找到了解决方案。

What you need to do is create a hidden input field and set the TargetControlID to the hidden control and from there you are able to fire off the buttons event. 您需要做的是创建一个隐藏的输入字段,并将TargetControlID设置为该隐藏的控件,然后您就可以触发按钮事件。

<input type="hidden" runat="server" id="hdnNext" />

<asp:ModalPopupExtender ID="ModalPopupExtender6" runat="server" TargetControlID="hdnNext" OkControlID="imgExitEdit1"
    PopupControlID="pnlIban" BackgroundCssClass="LoadingBackground" >
</asp:ModalPopupExtender>

The input field is used in this case as a Dummy control where the ModalPopupExtender points to and from the buttons event you are able to control which other ModalPopupExtenders you want to control. 在这种情况下,输入字段用作虚拟控件,其中ModalPopupExtender指向和来自按钮事件,您可以控制要控制的其他ModalPopupExtenders。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM