This is an old solution to an old problem, but since somebody asked
me if I knew how to solve this problem, I thought I'd post the solution
here to make it easier for people to find in the future.
The problem has to do with ASP.Net and modal windows. If you've ever
launched a modal window and issued a postback by clicking a button or
tried to redirect, you know that it always opens a brand new window,
and that is super annoying and unusable.
So, if you want to know how to use modal windows in Asp.Net and not
have them keep opening new windows, the solution (and I my friend will
can testify this simple solution works) does work. There are much more
elaborate solutions posted out on the internet, but trust me, its just
this easy, even though slightly inconvenient.
First, in the HEAD of EACH PAGE that will be as a modal window or called from a modal window, you have to have the following:
<script language="javascript">window.name="DefaultPage"</script>
This name you give each page MUST be unique for each page.
Now, just set the target of the form in your page to target the name of the page the form exists on, like such:
<form id="form1" runat="server" target="DefaultPage">
With a completely new and blank page, the whole thing would look like this:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">window.name="DefaultPage"</script>
</head>
<body>
<form id="form1" runat="server" target="DefaultPage">
<div>
</div>
</form>
</body>
</html>
Read: Making modal dialog windows work in ASP.Net the easy way