Connecting Tech Pros Worldwide Forums | Help | Site Map

Window Does not close

Vijay Kerji
Guest
 
Posts: n/a
#1: Nov 19 '05
Hi:

I have a child window which is opened by parent using ShowModalDialog.
Child has a button called Add and its click handler at server tries to
close the window as below.

private void Button_Add_Click(object sender, System.EventArgs e)
{
string strscript = "<script
language=javascript>window.top.close();</script>";
if (!Page.IsStartupScriptRegistered("clientScript"))
Page.RegisterStartupScript("clientScript",
strscript);
}

But unfortunately, child window does not get closed. Any guess is very
much appreciated.

Thanks in Advance,

Vijay K Kerji

Lau Lei Cheong
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Window Does not close


First, make sure the code is executed. Sometimes due to varies reasons such
as forgotten to add a <from runat="server"> tag will cause the button
non-functional.

Second, just be curious, why do you want to execute "window.top.close()"
instead of "window.close"?

Third, another curious question, why do you want a server-side button to
handle what is normally handled by client side button?

"Vijay Kerji" <vijay_kerji@yahoo.com> ???
news:303681ba.0412122304.7361ddd2@posting.google.c om ???...[color=blue]
> Hi:
>
> I have a child window which is opened by parent using ShowModalDialog.
> Child has a button called Add and its click handler at server tries to
> close the window as below.
>
> private void Button_Add_Click(object sender, System.EventArgs e)
> {
> string strscript = "<script
> language=javascript>window.top.close();</script>";
> if (!Page.IsStartupScriptRegistered("clientScript"))
> Page.RegisterStartupScript("clientScript",
> strscript);
> }
>
> But unfortunately, child window does not get closed. Any guess is very
> much appreciated.
>
> Thanks in Advance,
>
> Vijay K Kerji[/color]


Fredrik Elestedt
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Window Does not close


A word of causion,

Popup-blockers such as the one included for IE in XP SP2 or in Mozilla
Firefox might not allow a JavaScript to be run at the time of page load.

"Vijay Kerji" <vijay_kerji@yahoo.com> wrote in message
news:303681ba.0412122304.7361ddd2@posting.google.c om...[color=blue]
> Hi:
>
> I have a child window which is opened by parent using ShowModalDialog.
> Child has a button called Add and its click handler at server tries to
> close the window as below.
>
> private void Button_Add_Click(object sender, System.EventArgs e)
> {
> string strscript = "<script
> language=javascript>window.top.close();</script>";
> if (!Page.IsStartupScriptRegistered("clientScript"))
> Page.RegisterStartupScript("clientScript",
> strscript);
> }
>
> But unfortunately, child window does not get closed. Any guess is very
> much appreciated.
>
> Thanks in Advance,
>
> Vijay K Kerji[/color]


Closed Thread