showModalDialog fires Page_Load only for first click

G

Guest

I am using javascript to open a popup window on a ImageButton click.

My Page_Load contains this code
btnNew.Attributes.Add("onclick","popNew()");

this is my javascript

function popNew()
{
window.showModalDialog("popNew.aspx",
null,"center:yes;resizable:no;dialogHeight:500px;dialogWidth:410px");
}


When I click on the ImageButton btnNew the first time, the Page_Load for
popNew fires. I save the details in the form and I do a
Response.Write("<script type='text/javascript'>window.close()</script>");

From the main form when I click the btnNew button for the 2nd time or more,
the Page_Load for popNew doesnt fire.

I am storing some some data in a hidden asp.net textbox in popNew. I clear
the data just before I do window.close() but when I click the button in the
main form and come to the popup the data in the textbox still exists.

If I use window.Open(), then I do not have this problem but again I am using
modalDialog to refresh the page when the popup is closed. With window.open my
code doesnt wait for the popup to close and the refresh takes place before
it needs to happen.

Is their something I am missing? What would be a solution to this?
 
L

Laurent Bugnion

Hi,

Tarakeshwar said:
> I am using javascript to open a popup window on a ImageButton click.
>
> My Page_Load contains this code
> btnNew.Attributes.Add("onclick","popNew()");
>
> this is my javascript
>
> function popNew()
> {
> window.showModalDialog("popNew.aspx",
> null,"center:yes;resizable:no;dialogHeight:500px;dialogWidth:410px");
> }
>
>
> When I click on the ImageButton btnNew the first time, the Page_Load for
> popNew fires. I save the details in the form and I do a
> Response.Write("<script type='text/javascript'>window.close()</script>");
>
> From the main form when I click the btnNew button for the 2nd time or more,
> the Page_Load for popNew doesnt fire.

<snip>

If the Page_Load event doesn't fire, then probably the page is loaded
from the cache, and no roundtrip is made.

One workaround is to use a unique query string, which will tell the
browser that the URL in question is not cached already.

For example
"popNew.aspx?" + ( new Date() ).getTime()

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top