How to close dialog box?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I have a question about closing a dialog box.
The thing is: I have two ASP.NET pages. From one page, I open another page
as window.showModalDialog. THere is a button on the second page. On the click
event of the button on second page, I put code "Response.Write("<script
language='javascript'> { self.close();}</script>")" or
"Response.Write("<script language='javascript'> {
window.close();}</script>")". But it doesn't work. WHen I click the button,
the page was not closed.
Any idea?
Thanks

william
 
Since its a modal dialog, it lacks the ability to do a postback!
So what you should do is to use pure javascript..
Hths..
R. Thomas
 
Modal dialog is just a sort of window where the browser handles a page in
absolutely normal way. There are no restrictions on postbacks whatsoever. I
have numerous dialogs with

Response.Write("<script language=\"Javascript\">window.close</script>");

and they work fine. Try removing {}.

Eliyahu
 
When a modal pop-up window is opened as a child window from a web-page, and a
asp button button is put on top of it, If that asp button is clicked, a
postback occurs(right?)... The unusual thing is, another window pops up... It
simply doesn't let one postback...
How are u able to achieve post back in this scenario Eliyahu?
 
When a modal pop-up window is opened as a child window from a web-page,
and a
asp button button is put on top of it, If that asp button is clicked, a
postback occurs(right?)... Right.

The unusual thing is, another window pops up...
Ah, that's what you mean. Fortunately, this problem has a very simple
solution. Just put
<base target=_self>
in the head section of the modal page.

Eliyahu
 
WOW!!!
My senior told me "Modal Dialogs cannot postback!!!"
In our company we have been coding keeping in mind that modal dialogs cannot
post back..
Sigh.. how many past things could I have code to be so much more elegant if
only, I had posted this question instead of blindly listening to my senior...
Thanks Eliyahu..
Regards
 
Yes, or you could've just googled the newsgroups. This is a common question.

Eliyahu
 
Back
Top