Click here to Skip to main content
16,016,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a model popup within a which a Button.When user click on this button it will post back and will perform some action. But after post back the model popup is disappearing.
I want show it again even after postback
for that in codebehind i wrote ModelPopup1.show();
but it will not display in the centre position

Please provide better method to display the modelpopup after postback
my code are as follows
//=======================
XML
<form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
    <div id="popupDiv" style="width:314px; height:267px; background-color:Yellow; text-align:centre; display:none">

        <asp:Button ID="BtnPostBack" runat="server" Text="PostBack"
            onclick="BtnPostBack_Click" /><br />
        <asp:Label ID="Label1" runat="server"></asp:Label><br />
        <asp:Button ID="btnclose" runat="server" Text="Close" />



    </div>


     <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
     CancelControlID="btnclose" Enabled="True" PopupControlID="popupDiv" TargetControlID="btnOpenPopup">
    </cc1:ModalPopupExtender>


        <asp:Button ID="btnOpenPopup" runat="server" Text="Click to Display Popup" />


    </div>
    </form>
Posted

Generally with postback ModalPopup get disable or invisible. You have to write ModalPopup1.Show(); Method after which u wants to show. you can set a counter in your program and against a button inside modal popup you can increse its value and in pageload you can check if its value is not incremented then Modalpopup1.Show();
This problem is solved in floating div. you can try floating div also inplace of modalpopup. It performs the same operation.
 
Share this answer
 
i got a good solution- put a button outside the ModalPopupExtender and submit the button by javascript and put java script code inside the okscript();Outside button cause postback.

<asp:modalpopupextender id="mpeSave" runat="server" backgroundcssclass="ModalPopupBG" xmlns:asp="#unknown">
BehaviorID="mpebSave" CancelControlID="btnPopupNo" DropShadow="True" OkControlID="btnPopupYes"
OnCancelScript="hidePanel('C')" OnOkScript="hidePanel('Y');" PopupControlID="pnlOverlaySave"
TargetControlID="pnlOverlaySave">


<asp:panel id="pnlOverlaySave" runat="server" horizontalalign="Left" style="display: none" xmlns:asp="#unknown">
Width="330px">



<asp:button id="btnReset" runat="server" text="Reset" onclick="btnReset_Click" xmlns:asp="#unknown">


function hidePanel(var1) {
window.$get('&lt;%= pnlOverlaySave.ClientID %&gt;').style.display = "none";
window.$find('mpebSave').hide();
if (var1 == 'Y') {
//this is the button event which cause postback
window.parent.document.getElementById('&lt;%=btnReset.ClientID %&gt;').click();

}
 
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