473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

ASP.NET Javascript Modal Popup won't fire Page Load on second go

Hello All

Hope you can help

Been pulling my hair out about a popup problem in ASP.NET. One of the
forms i wrote requires the user to select a product from a list in a
popup web form. the popup has a DataGrid on it and the page.load
function DataBinds as you'd expect.

I have Code-Behind in C# to emit a call to a JavaScript function which
uses showModalDialog() to show the popup. The product list is selected
from the parent page and inserted into a Session[] variable. This
Session[] variable is picked up by the popup and binds to the datagrid
successfully. A little more JavaScript is emitted in the popup to get
an array of data back to the parent, and also call window.close().

However, when the user has to select a second product, the popup
doesn't fire it's Page.load method and the DataGrid remains with it's
old data. The data is definitely in the Session[] store as i expected
it.

How can i get the popup to close properly so that the page.load event
fires every time?

hope it makes sense

Nov 19 '05 #1
15 10043
> How can i get the popup to close properly so that the page.load event
fires every time?


Not sure but I think the window.open() call has an attribute to name the
opening window (for ref) and if so try generating a random name (time
perhaps) as the name to ensure it's a "new" window...

Just a quick thought

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #2
if i've understood this properly, you are trying to get the Parent page to
reload once you have finished with the popup window.

If this is the case, as well as closing the popup, try redirect the Parent
page to itself

javascript: window.opener.parent.location='MyUrl.aspx';

HTH

"H00ner" <ti*@slashwoot.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello All

Hope you can help

Been pulling my hair out about a popup problem in ASP.NET. One of the
forms i wrote requires the user to select a product from a list in a
popup web form. the popup has a DataGrid on it and the page.load
function DataBinds as you'd expect.

I have Code-Behind in C# to emit a call to a JavaScript function which
uses showModalDialog() to show the popup. The product list is selected
from the parent page and inserted into a Session[] variable. This
Session[] variable is picked up by the popup and binds to the datagrid
successfully. A little more JavaScript is emitted in the popup to get
an array of data back to the parent, and also call window.close().

However, when the user has to select a second product, the popup
doesn't fire it's Page.load method and the DataGrid remains with it's
old data. The data is definitely in the Session[] store as i expected
it.

How can i get the popup to close properly so that the page.load event
fires every time?

hope it makes sense

Nov 19 '05 #3
and just found on google, you can also do:

javascript: window.opener.location.reload()

"H00ner" <ti*@slashwoot.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello All

Hope you can help

Been pulling my hair out about a popup problem in ASP.NET. One of the
forms i wrote requires the user to select a product from a list in a
popup web form. the popup has a DataGrid on it and the page.load
function DataBinds as you'd expect.

I have Code-Behind in C# to emit a call to a JavaScript function which
uses showModalDialog() to show the popup. The product list is selected
from the parent page and inserted into a Session[] variable. This
Session[] variable is picked up by the popup and binds to the datagrid
successfully. A little more JavaScript is emitted in the popup to get
an array of data back to the parent, and also call window.close().

However, when the user has to select a second product, the popup
doesn't fire it's Page.load method and the DataGrid remains with it's
old data. The data is definitely in the Session[] store as i expected
it.

How can i get the popup to close properly so that the page.load event
fires every time?

hope it makes sense

Nov 19 '05 #4
I saw that option of window.open() but, unfortunately, I'm using
window.showModalDialog() which returns a variant from the modal box and
not a reference to the page.

thanks for the reply though Curt :¬)

Nov 19 '05 #5
Grant Merwitz wrote:
if i've understood this properly, you are trying to get the Parent page to
reload once you have finished with the popup window.


Actually I think he's indicating that the second time he tries to call
the window.open() it doesnt.... because he suspects it isnt closing
properly??

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #6
thanks Grant, but it's not the parent that needs to be reloaded.

The process works like this :

Parent window selects data to be displayed in popup and stores in
session
Parent emits javascript to call showModalDialog() and popup loads
Popup gets data from session and binds to datagrid
User selects data they want and popup returns a JavaScript array
Parent uses javascript array to fill text boxes

This all works okay on the first run through, but the popup will not
fire it's Server-Side Page.Load method when it's called a Second time
and the new data selected by the parent isn't bound to the DataGrid.
It seems that the popup page is still 'loaded' and the JavaScript
window.close() doesn't unload it entirely

Nov 19 '05 #7
H00ner wrote:
I saw that option of window.open() but, unfortunately, I'm using
window.showModalDialog() which returns a variant from the modal box and
not a reference to the page.

thanks for the reply though Curt :¬)


I'm not really concerned with the return from the call, more of the
actual call. I was just wondering if the browser was seeing the same
call twice and not calling it.. was thinking that an appended
QueryString random value or new name may "fool" the browser into
thinking its a different window.

Personally I've avoided the modal windows due to the NASTY problems I
always run into. A well placed/positioned window.open() call is usually
sufficient. It is definitely an area that WWW has a deficiency in.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #8
You could be on to something there Curt. I was trying to force the
users to give me the data using a modal dialog box. However, i could
use a window.open() instead really as this does give a reference to the
window i've opened which i should be able to nullify when i'm done

thanks for your feedback (and you, Grant) on my issue. I'll update
this thread with my findings using window.open() instead of
window.showModalDialog()

You're also right about the deficiancy thing as well. i'm hoping
there's something to help us more when ASP.NET 2.0 emerges :¬)

cheers

Tim

Nov 19 '05 #9
> You're also right about the deficiancy thing as well. i'm hoping
there's something to help us more when ASP.NET 2.0 emerges :¬)


Sadly its not a programming limitation that much.. mostly its a Browser
thing. WWW wasn't really designed around the idea of multiple,
interconnected, windows. It was supposed to be a single call, processed
and returned then dropped. Everything beyond that is really just
"project drift"......

-
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #10
i've had a think about the window.open() thing as well and my project
relies on the returned array from showModalDialog() so it can collect
the data into the desired boxes.

do you know if there's any way of calling a page's Dispose() method
from another page? Maybe i could ensure the page is unloaded before I
emit the JavaScript to pop the box up

i'll have another play tomorrow and see what happens

thanks for all your suggestions :¬)

Tim

Nov 19 '05 #11
"H00ner" wrote:
but the popup will not
fire it's Server-Side Page.Load method when it's called a Second time
and the new data selected by the parent isn't bound to the DataGrid.
It seems that the popup page is still 'loaded' and the JavaScript
window.close() doesn't unload it entirely


Page loads the previous data, when clicked second time ?

The issue should be BROWSER CACHING the data.. use this code in popup page
page_load to expire the cache..
private void Page_Load(object sender, System.EventArgs e)
{
ExpirePageCache();
//.......rest of the page_load logic....................
}
/// <summary>
/// This function prevent the page being retrieved from broswer cache
/// </summary>
private void ExpirePageCache()
{
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(fa lse);
}

pls let us know if it worked.. Thanks

Sreejith

Nov 19 '05 #12
an additional note, this happense when you do not have any query parameter
passed (or pass same query param value in susequent calls) to the popup ..

Adding a dummy query parameter param with some random value passed as
parameter every time also could solve the issue..

"Sreejith Ram" wrote:
"H00ner" wrote:
> but the popup will not
fire it's Server-Side Page.Load method when it's called a Second time
and the new data selected by the parent isn't bound to the DataGrid.
It seems that the popup page is still 'loaded' and the JavaScript
window.close() doesn't unload it entirely


Page loads the previous data, when clicked second time ?

The issue should be BROWSER CACHING the data.. use this code in popup page
page_load to expire the cache..
private void Page_Load(object sender, System.EventArgs e)
{
ExpirePageCache();
//.......rest of the page_load logic....................
}
/// <summary>
/// This function prevent the page being retrieved from broswer cache
/// </summary>
private void ExpirePageCache()
{
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(fa lse);
}

pls let us know if it worked.. Thanks

Sreejith

Nov 19 '05 #13
H00ner wrote:
i've had a think about the window.open() thing as well and my project
relies on the returned array from showModalDialog() so it can collect
the data into the desired boxes.

do you know if there's any way of calling a page's Dispose() method
from another page? Maybe i could ensure the page is unloaded before I
emit the JavaScript to pop the box up

i'll have another play tomorrow and see what happens

thanks for all your suggestions :¬)

Tim


save the data, call the calling-pages Refresh() when complete

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #14
Sreejith

These both worked.

i added a javascript method to return a random generated querystring
which i then appended to my URL in showModalDialog() and this caused
the page to load every time

Also, i tried the Response.Cache() method you gave me and that works
also. i prefer this method to the random querystring as the code is
all server-side and easy to locate

thanks your help on this, problem solved :¬)

Tim

Nov 19 '05 #15
it's a bit of a weird page in most respects. the page starts by asking
the user to select one of our clients and then goes off to cache the
client's product list so that the popup loads a bit quicker. this
selection also makes visible a whole swath of panels and tables with
fields in them.

Sreejith had the solution up above and it was due to browser caching.
invalidating the cache or tricking the browser into thinking it's a
different link sorted it out :¬)

I'd like to thank you all for your time on my issue and replying to me.
it's really helped me out

cheers

Tim

Nov 19 '05 #16

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

Similar topics

2
by: Samy | last post by:
Hi There, I have a user control with buttons on it which I use on a aspx page (parent page). On a button click, a modal dialog(aspx page) opens up and the user enters some info in the modal dialog...
7
by: Mardy | last post by:
I have a datagrid with a linkbutton for editing. I'm trying to run some javascript when the link button is clicked to show a wait message. Everything works fine the first time after the page loads...
1
by: Slavo Smutny | last post by:
Hi, which is better approach to store my JavaScript code, to store it in separate .js file or to embed the code within HTML attributes (e.g. <p onclick="javascript:submit();">click this</p>)? I...
1
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the...
1
rrocket
by: rrocket | last post by:
I am trying to get a modal popup to display on an onblur event, but I keep getting a "'null' or is null or not an object" js error. I have seen many examples using var _popup; _popup =...
4
by: fran_j_diaz | last post by:
Hi, I have a page with an Ajax modal popup. I would like to know when my Modal popup is opened, my page still able to modify. Is it possible ? (I use Visual Studio 2005, c# )
3
by: Mike Hofer | last post by:
Okay, here's the situation: we want to be able to display ASPX pages in an UpdatePanel. The reasons for this are performance related. The site in development uses *lots* of modal popups from some...
5
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
Hi all Have a couple of issues with the modal popup extender (asp.net 3.5, vb.net, visual studio 2008): I have created a user control (e-mail enquiry form) which is designed to accept text...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.