Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

I did something like this.

XML
<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>


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.
Posted
Comments
Sandeep Mewara 26-Apr-11 11:26am    
Not clear on your issue. Is AutoEventWireup set to true? Did you debug and see if the execution is getting on server side?
Mohd Wasif 27-Apr-11 0:42am    
yes i debugged it but it is not getting server side
Shahriar Iqbal Chowdhury/Galib 27-Apr-11 16:10pm    
is panel and ModalPopupExtender under update panel?

hi, try this one this will work

XML
<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

MIDL
lblMsg.Text = "You will Never  shutdown the real napster";
           MPE.Show();
 
Share this answer
 
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>
 
Share this answer
 
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
 
Share this answer
 
Comments
golineelu 21-Mar-12 15:08pm    
I tried this.It worked. Thanks a lot...
Laiju k 2-Jul-14 2:34am    
thanks
You will need a dummy button control to achieve this behaviour.
Steps would be:

1. Have your normal cancel button on the page
2. Have a invisible dummy cancel button with the CSS Style as display:none (strictly not Visible="false")
3. Have your popup panel on the page
4. Have your modal popup extender on the page with TargetControlID as your dummy cancel button ID

Now when you click on the normal cancel button (click event in the code behind),

Cancel button click event
{
//Do whatever stuffs as disabling button or whatever other operation
ModalPoupUpExtenderID.Show()
}


This should work. Let me know if you have any other questions.

-Nayan
Coding is an earthly heaven

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900