473,574 Members | 3,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to Close Popup window using ASP.Net

I am having a problem closing a popup window opened modally. When I
try to close the window (when the user hits save button and the data
has been processed), the Popup window opens as a full screen as a new
window. The original window plus the Modally opened Pop remain in a
separate window.

What I want to do is close the popup and return to the original window
with its view state maintained.

The control use to fire the popup window and the one to save the
changes need to be a web server control.
The popup window needs to be modal.
*************** *************** *************** *************** ***************
The code I am using open the window with this control is:

private void butChangeOrder_ Click(object sender, System.EventArg s e)
{
if (!IsClientScrip tBlockRegistere d("OpenPopup" ))
{
RegisterClientS criptBlock("Ope nPopup", "<script
language=\"java script\">window .showModalDialo g('PopUpSortOrd er.aspx',null,' font-size:10px;dialo gWidth:43em;dia logHeight:40em,
toolbar=0,locat ion=0,directori es=0,status=no, menuBar=1,scrol lBars=no,resiza ble=no')</script>");
}
}

*************** *************** *************** *************** ***************

The code that I am using to close the Popup window is:

private void butSaveOrder_Cl ick(object sender, System.EventArg s e)
{
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings ();
dtSave.SaveSort Orders(false,Hi ddenIds );

if( !Page.IsClientS criptBlockRegis tered ("ClosePopUp "))
{
RegisterClientS criptBlock("Clo sePopUp", "<script
language=\"java script\">functi on
CloseMe(){windo w.close();windo w.history.back( ); };</script>");
}
butSaveOrder.At tributes.Add("o nclick", "ClosePopUp()") ;
}
*************** *************** *************** *************** ***************
Hopefully someone has a solution in this regard.

Cheers.

GrantS
Nov 15 '05 #1
4 34849
Try to write out the script directly to the page after the save of data.

<code>
private void butSaveOrder_Cl ick(object sender, System.EventArg s e)
{
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings ();
dtSave.SaveSort Orders(false,Hi ddenIds );
Response.Write( "<script language=\"Java script\">window .opener =
self;window.clo se();</script>");
Response.End();
}
</code>

The window.opener = self statement is to bypass the annoying message box
that IE throws at you when trying to close a window from javascript.

--
Patrik Löwendahl
cshrp.net - " Elegant code by witty programmers "
cornerstone.se - " IT Training for professionals "
"GrantS" <su************ *@hotmail.com> wrote in message
news:69******** *************** **@posting.goog le.com...
I am having a problem closing a popup window opened modally. When I
try to close the window (when the user hits save button and the data
has been processed), the Popup window opens as a full screen as a new
window. The original window plus the Modally opened Pop remain in a
separate window.

What I want to do is close the popup and return to the original window
with its view state maintained.

The control use to fire the popup window and the one to save the
changes need to be a web server control.
The popup window needs to be modal.
*************** *************** *************** *************** *************** The code I am using open the window with this control is:

private void butChangeOrder_ Click(object sender, System.EventArg s e)
{
if (!IsClientScrip tBlockRegistere d("OpenPopup" ))
{
RegisterClientS criptBlock("Ope nPopup", "<script
language=\"java script\">window .showModalDialo g('PopUpSortOrd er.aspx',null,' f
ont-size:10px;dialo gWidth:43em;dia logHeight:40em, toolbar=0,locat ion=0,directori es=0,status=no, menuBar=1,scrol lBars=no,resiza b
le=no')</script>"); }
}

*************** *************** *************** *************** ***************
The code that I am using to close the Popup window is:

private void butSaveOrder_Cl ick(object sender, System.EventArg s e)
{
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings ();
dtSave.SaveSort Orders(false,Hi ddenIds );

if( !Page.IsClientS criptBlockRegis tered ("ClosePopUp "))
{
RegisterClientS criptBlock("Clo sePopUp", "<script
language=\"java script\">functi on
CloseMe(){windo w.close();windo w.history.back( ); };</script>");
}
butSaveOrder.At tributes.Add("o nclick", "ClosePopUp()") ;
}
*************** *************** *************** *************** *************** Hopefully someone has a solution in this regard.

Cheers.

GrantS

Nov 15 '05 #2
> if( !Page.IsClientS criptBlockRegis tered ("ClosePopUp "))
{
RegisterClientS criptBlock("Clo sePopUp", "<script
language=\"java script\">functi on
CloseMe(){windo w.close();windo w.history.back( ); };</script>");
}
butSaveOrder.At tributes.Add("o nclick", "ClosePopUp()") ;
}


Well, the button's onclick event should be wired to CloseMe(), not to
ClosePopUp (that's just the scripts key).

Another thing is that you call window.close() and then
window.history. back()... doesn't this mean you are trying to naviagate
backwards on a closed window?

Hope that helps,
-JG
Nov 15 '05 #3
N
You can try this

set <base target="_self"> for the popup window page and
then on click of the save button, save the data and then
do
RegisterStartup Script("winclos e","<script>win dow.close
();</script>");.

Hope this helps,
N
-----Original Message-----
I am having a problem closing a popup window opened modally. When Itry to close the window (when the user hits save button and the datahas been processed), the Popup window opens as a full screen as a newwindow. The original window plus the Modally opened Pop remain in aseparate window.

What I want to do is close the popup and return to the original windowwith its view state maintained.

The control use to fire the popup window and the one to save thechanges need to be a web server control.
The popup window needs to be modal.
************** *************** *************** ************** *************** **The code I am using open the window with this control is:

private void butChangeOrder_ Click(object sender, System.EventArg s e) {
if (!IsClientScrip tBlockRegistere d ("OpenPopup" )) { RegisterClientS criptBlock ("OpenPopup" , "<scriptlanguage=\"jav ascript\">windo w.showModalDial og ('PopUpSortOrde r.aspx',null,'f ont-
size:10px;dialo gWidth:43em;dia logHeight:40em,toolbar=0,loca tion=0,director ies=0,status=no ,menuBar=1,scr ollBars=no,resi zable=no')</script>"); }
}

************** *************** *************** ************** *************** **
The code that I am using to close the Popup window is:

private void butSaveOrder_Cl ick(object sender, System.EventArg s e) {
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings (); dtSave.SaveSort Orders (false,HiddenId s );
if( ! Page.IsClientSc riptBlockRegist ered ("ClosePopUp ")) {
RegisterClientS criptBlock ("ClosePopUp ", "<scriptlanguage=\"jav ascript\">funct ion
CloseMe(){wind ow.close();wind ow.history.back (); };</script>"); }
butSaveOrder.At tributes.Add ("onclick", "ClosePopUp()") ; }
************** *************** *************** ************** *************** **Hopefully someone has a solution in this regard.

Cheers.

GrantS
.

Nov 15 '05 #4
"Patrik Löwendahl" <pa************ **@csharpsweden .com> wrote in message news:<uk******* *******@TK2MSFT NGP10.phx.gbl>. ..
Try to write out the script directly to the page after the save of data.

<code>
private void butSaveOrder_Cl ick(object sender, System.EventArg s e)
{
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings ();
dtSave.SaveSort Orders(false,Hi ddenIds );
Response.Write( "<script language=\"Java script\">window .opener =
self;window.clo se();</script>");
Response.End();
}
</code>

The window.opener = self statement is to bypass the annoying message box
that IE throws at you when trying to close a window from javascript.

--
Patrik Löwendahl
cshrp.net - " Elegant code by witty programmers "
cornerstone.se - " IT Training for professionals "
"GrantS" <su************ *@hotmail.com> wrote in message
news:69******** *************** **@posting.goog le.com...
I am having a problem closing a popup window opened modally. When I
try to close the window (when the user hits save button and the data
has been processed), the Popup window opens as a full screen as a new
window. The original window plus the Modally opened Pop remain in a
separate window.

What I want to do is close the popup and return to the original window
with its view state maintained.

The control use to fire the popup window and the one to save the
changes need to be a web server control.
The popup window needs to be modal.

*************** *************** *************** *************** ***************
The code I am using open the window with this control is:

private void butChangeOrder_ Click(object sender, System.EventArg s e)
{
if (!IsClientScrip tBlockRegistere d("OpenPopup" ))
{
RegisterClientS criptBlock("Ope nPopup", "<script

language=\"java script\">window .showModalDialo g('PopUpSortOrd er.aspx',null,' f
ont-size:10px;dialo gWidth:43em;dia logHeight:40em,

toolbar=0,locat ion=0,directori es=0,status=no, menuBar=1,scrol lBars=no,resiza b
le=no')</script>");
}
}

*************** *************** *************** *************** ***************

The code that I am using to close the Popup window is:

private void butSaveOrder_Cl ick(object sender, System.EventArg s e)
{
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings ();
dtSave.SaveSort Orders(false,Hi ddenIds );

if( !Page.IsClientS criptBlockRegis tered ("ClosePopUp "))
{
RegisterClientS criptBlock("Clo sePopUp", "<script
language=\"java script\">functi on
CloseMe(){windo w.close();windo w.history.back( ); };</script>");
}

butSaveOrder.At tributes.Add("o nclick", "ClosePopUp()") ;
}

*************** *************** *************** *************** ***************
Hopefully someone has a solution in this regard.

Cheers.

GrantS


Excellent! Thanks folks for the suggestions. I played with each of the
suggestions and turns out the the suggestion by N does what exactly
what I need. Bingo!
Code below with the last line being the one for others to use in this
situation.
Patrick's suggestion helped in that it did not throw up the extra
form, so I could have used it in the save and gotten rid of the close
button. The user could still close using the control box.
I played with the things Juan suggested but no go.

*************** *************** *************** *************** *************** *************** *****

private void butSaveOrder_Cl ick(object sender, System.EventArg s e)
{
DataSavings dtSave = new CMSDataViewer.U tilities.DataSa vings ();
dtSave.SaveSort Orders(false,Hi ddenIds );
/*
//Suggestion 1 (Patrick): Saves but does not close PopUp(At least
does not Open another window).
Response.Write( "<script language=\"Java script\">window .opener
= self;window.clo se();</script>");
Response.End();
//Suggestion 2 (JUan):My Original with Navigate before Close and the
ClosePopUp used consistently
if( !Page.IsClientS criptBlockRegis tered ("ClosePopUp "))
{
RegisterClientS criptBlock("Clo sePopUp", "<script
language=\"java script\">functi on
ClosePopUp(){wi ndow.history.ba ck();window.clo se(); };</script>");
}
butSaveOrder.At tributes.Add("o nclick", "ClosePopUp()") ;
*/

//Suggestion 3 (N). This does the trick: - uses <base target="_self">
in page header:
RegisterStartup Script("winclos e","<script>win dow.close();</script>");

}

*************** *************** *************** *************** *************** *************** *****
Thanks again. Grant
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5659
by: Colin Graham | last post by:
Hi guys, Just a quickie here that i hope someone can help me with. Basically i want stop the user from closing the popup window using the small x button in the top right hand corner. Im aware that i cant disable this so i thought is it possible to do a check to see if a hidden text on the main form has a value. E.g. if we close the popup...
10
3063
by: soup_or_power | last post by:
The pop up window has several checkboxes. I'm unable to access the checkboxes using the handle from window.open. Any way to do this? var display; function showSugg(but_id, sugg1, sugg2, sugg3, sugg4, sugg5) { display=window.open('','_blank','menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=150,width=190')
7
2591
by: Drew Berkemeyer | last post by:
Hello, We have an application that we have written using ASP.NET. On one of our pages we open a popup window using javascript. The popup window has a save and a cancel button. Both of them are server-side controls and do a postback. While processing on the server we add javascript to the page load (i.e. onload=window.opener.focus();...
4
1913
by: louise raisbeck | last post by:
I have this scenario (simplified) function addnewdata () { check for partial match already in db for information entered by user if (partialmatch succeeds) { open new window aspx page (using javascript) with a datagrid of these partial match records (by doing a sqlcommand using some query string values taken from opener data entered) ***...
0
1533
by: aiasso | last post by:
Hi All, Need big time help with this one. I'm using Forms Authentication with an ASP.NET (VB.NET) web app, and everything is fine until the client opens a popup window using javascript on the client side. The problem is that when they close the popup window (either closing the window with the X button or with the close method on the java...
2
2669
by: julie.siebel | last post by:
I KNOW this can't be as hard as I am making it. I have a travel client with two related websites. On the homepage of the new site (Call it "Site A") I am building for them, there is a link to a popup window that includes the European regions both companies offer (Links to both site A and site B). If they click on a region that is a "Site...
5
3075
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any ideas?
2
6745
by: kurt sune | last post by:
Hello, I have a weird problem, I hope someone can explain this for me. I have a webpage using masterpage. In it I create a popup window using this code: Dim js As String = "<script language=javascript>" js &= "var newWin = window.showModalDialog('InkommetVi.aspx" js &= "',null,"
1
3202
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit button". when "submit" button pressed, call the "servlet" in this popup window and then close the "popup" window. <SCRIPT LANGUAGE="JavaScript"> ...
0
7841
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8271
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6511
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5335
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3774
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2273
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1099
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.