The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Making modal dialog windows work in ASP.Net the easy way

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Raymond Lewallen

Posts: 312
Nickname: rlewallen
Registered: Apr, 2005

Raymond Lewallen is a .Net developer and Sql Server DBA
Making modal dialog windows work in ASP.Net the easy way Posted: Dec 8, 2005 7:04 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Raymond Lewallen.
Original Post: Making modal dialog windows work in ASP.Net the easy way
Feed Title: Raymond Lewallen
Feed URL: /error.htm?aspxerrorpath=/blogs/raymond.lewallen/rss.aspx
Feed Description: Patterns and Practices, OOP, .Net and Sql
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Raymond Lewallen
Latest Posts From Raymond Lewallen

Advertisement

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

Topic: Things will be slower (than usual) around here... Previous Topic   Next Topic Topic: Preliminary Code Camp Schedule

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use