ShowModalDialog of javascript is not closing from ASP Code behind and opens a new pop up of same page


Introduction: What is and why to use SHowModalDialog : 

In Many application, many of popups are implemented using window.showmodaldialog which restricts user to finish work on popup before changing focus to any other part of application.  For exaple just try to shut down your Smartphone and you will be prompt with a message that will force you to confirm your decision which probably uses ModalPopUp. It freezes everything in backgrund and without getting any input from your side it doesn't allow you to change something in background
page.

Issue :

Generally an issue comes that while using ShowModalDialog of javascript doesn't closes from ASP Code behind and opens a new pop up of same page. To solve this issue just add <base target="_self"/> in <head> tag. Below I have shown an example how to use a ShowModalDialog and close it.

<head runat="server">
<base target="_self" />
<title></title>
</head>

protected void ButtonClose_Click(object sender, EventArgs e)
{
Response.Write("<script language='javascript'> { self.close() }</script>");
}

Comments

Popular posts from this blog

How to show enlarge image when mouse hover on image or link in Asp.Net(c#) using JavaScript

StateCode and StatusCode Values for mostly used entities in Microsoft Dynamics CRM 2013

How to add custom filter lookup field based on OptionSet field selection in Dynamics CRM.

go to top image