Pop up window opened from code behind is not getting closed
i am opening a pop up from code behind(which i am using as waiting image while processing) after that i am doing some activity in background ,when the activity is done i am closing that pop up . the problem is after the activity is over the pop is not getting closed. what i am doing wrong, here is my code snippet:-
System.Text.StringBuilder sb = new System.Text.Strin开发者_如何学CgBuilder();
sb.Append("<script language='javascript'>");
sb.Append("var win=");
sb.Append("window.open('WaitingImage.aspx', 'Wait',");
sb.Append("'width=800, height=600, menubar=no, resizable=no');window.focus();<");
sb.Append("/script>");
Type t = this.GetType();
if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
{
ClientScript.RegisterClientScriptBlock(t,"PopupScript", sb.ToString());
}
//pop up opened.. now do the processing :-
uploadFiles();
//now close the pop up after work is done:-
System.Text.StringBuilder sbs = new System.Text.StringBuilder();
sbs.Append("<script language='javascript'>");
sbs.Append("window.close()");
sbs.Append("/script>");
Type tr = this.GetType();
ClientScript.RegisterClientScriptBlock(tr, "PopupScript", sbs.ToString());
You assign the popup to the win variable, but when you closee you call window.close...
Try to change
sbs.Append("window.close()");
to
sbs.Append("win.close()");
精彩评论