ASP.NET按钮无法在模式弹出扩展器上触发 [英] Asp.net button not firing on modal pop up extender

查看:69
本文介绍了ASP.NET按钮无法在模式弹出扩展器上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我做了这样的事情.

Hi All,

I did something like this.

<asp:Panel ID="Panel2" runat="server" BorderColor="Red" BorderStyle="Solid"

            Width="30%" BackColor="#EEEEEE">
            !<span class="style1">!! Have you informed to your Seniors? !!! </span>
            <br />
            <asp:Button ID="OkButton" runat="server" Text="Yes" onclick="OkButton_Click" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="CancelButton" runat="server" Text="No"

                onclick="CancelButton_Click" />

        </asp:Panel>
        <cc1:ModalPopupExtender ID="Panel2_ModalPopupExtender" runat="server" TargetControlID="lstReason"

          PopupControlID="Panel2"

 OkControlID="OkButton"

 CancelControlID="CancelButton"

            DynamicServicePath="" Enabled="True" >
        </cc1:ModalPopupExtender>



这里lstReason是一个列表框
现在,当我单击CancelButton
什么也没发生.
在CancelButton_Click事件中
我禁用了一个按钮,但是什么也没发生.

请帮帮我.



here lstReason is a listbox
right now when i am clicking CancelButton
nothing is happening .
On CancelButton_Click event
i disabled a button but nothing is happening.

Please help me.

推荐答案

试试这个可以用的方法

try this one this will work

<div>
    <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
    <cc1:ModalPopupExtender ID="MPE" runat="server" CancelControlID="btnCancel"

    TargetControlID="HiddenField1" PopupControlID="MessageDiv" BackgroundCssClass="popupbg">
     </cc1:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />
<div runat="server" id="MessageDiv" style="width: 450px;display: none;">
<asp:Label ID="lblMsg" runat="server"></asp:Label><br />
<asp:Button ID="btnOK" runat="server" Text="Ok" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />

    </div>
    </div>




在代码后面,即在您的按钮中单击




on code behind ie in your button click

lblMsg.Text = "You will Never  shutdown the real napster";
           MPE.Show();


尝试这个

hi try this

// For this Quest right now when i am clicking CancelButton
//nothing is happening .

On CancelButton_Click event

//if you want to generate Cancel click event in code behind you need to remove 

CancelControlID="btnCancel" from you Model Pop Up Like 

<asp:modalpopupextender id=""Panel2_ModalPopupExtender"" runat=""server"" targetcontrolid=""LinkButton1"<br" mode="hold" xmlns:asp="#unknown" />            PopupControlID="Panel2" OkControlID="OkButton" DynamicServicePath="" Enabled="True">
        </asp:ModalPopupExtender>


HI删除modalpopup扩展程序的 CancelControlID ="CancelButton" 属性,然后按钮的click事件将起作用.

将OkControlID设置为按钮时会发生什么情况,是modalpopup扩展程序抑制按钮的click事件.如果您以ajax方式处理数据插入,这将很有帮助.

但是在您的情况下,您希望触发按钮的click事件,因此删除上述属性将使您的按钮事件触发.

敢于与众不同
HI Remove CancelControlID="CancelButton" property of your modalpopup extender then the click event of the button will work.

What happens when set the OkControlID to the button is the modalpopup extender suppresses the click event of the button.This will be helpful if you handling the data insertion in ajax way.

But in your case you want the click event of the button to be fired,so removing the above said property will make your button event fire.

DARE TO BE DIFFERENT


这篇关于ASP.NET按钮无法在模式弹出扩展器上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆