Reputation: 2192
I am showing ajaxcontrol tool kit ModalPopupExtender to show from code behind on button click. On my button click I am uploading files and sending email, and after Emailing I am showing Modal Popup for few seconds then I am redirecting user to index page.
The problem I am having is that ModalPopup is only showing if I am not redirecting This is my aspx code
<input type="btmodel" runat="server" style="display: none">
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btmodel"
PopupControlID="Panel1" PopupDragHandleControlID="PopupHeader" Drag="true" DropShadow="true"
OkControlID="OkButton" CancelControlID="CancelButton" BackgroundCssClass="ModalPopupBG">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="Panel1" Style="display: none" runat="server">
<div class="HellowWorldPopup">
<div class="PopupHeader" id="PopupHeader">
Progress</div>
<div class="PopupBody">
<p>
Processing.....</p>
</div>
<div class="Controls">
<input id="btnOkay" type="button" value="Ok" onclick="OkScript()" />
</div>
</div>
</asp:Panel>
and my button click code
protected void btnupload_Click(object sender, EventArgs e)
{
//File uploading
//Sending Email
ModalPopupExtender1.Show();
Response.Redirect("Default.aspx");//If I comment this line,then modal is showing
}
I also tried with this before ModalPopupExtender1.Show(),but no luck
System.Threading.Thread.Sleep(1000);
Upvotes: 0
Views: 1745
Reputation: 2477
Make yourself aware that in an ASP.NET (or any webserver/client browser environment), your server-side code will be executed till the end, THEN a result is sent to the client browser. It is not a back-and-forth kind of communication by design.
Upvotes: 1
Reputation: 13960
The point is to make the redirection when the user close the popup, not when you're showing it. Write code to handle the "OnOkScript" or "OnCancelScript" and make the redirection there instead.
Upvotes: 1