Not able to close Modal Dialog box

G

Guest

Hi,
I am opening an Modal dialog box using the window.Showmodaldialogbox(), and
in that window i am having an aspx form with say one ASP.NET Button control.

i am doing some operation on the click event of the button control on the
server and finally closing the window by using the following statement at the
end of the click event of the button:
Response.Write("<script language='javascript'>window.close();</script>");

But instead of closing the windw, its poping up same window once again.

This behavior is specifict to the window.Showmodaldialogbox(), if i will
use simple window.open() then everything works fine.

i also tried to add the attribute to the button control but its giving the
same problem.
Button1.Attributes.Add("onclick","window.close()");

Can anybody help me out in this case to close the window after performing
some operation in the click event of the button.

Thanks
Hitesh
 
G

Guest

Thanks Eliyahu! its closing now. But now i am in another problem, since you
have given such a cleaner solution so i just want to consult you why this is
happening. See i am having the following statements at the end the click
event:

Response.Write("<script
language='javascript'>window.opener.document.getElementById('" + fieldName
+"_ImageControl').src='" + @imagePath + "';</script>");

Response.Write("<script
language='javascript'>window.opener.document.getElementById('" + fieldName
+"_DimentionLabel').innerText='" + dimentionLabelText + "';</script>");

Response.Write("<script
language='javascript'>window.opener.document.getElementById('" + fieldName
+"_ShowImageLink').innerText='Click Image to view actual size';</script>");

Response.Write("<script language='javascript'>window.close();</script>");

Now after adding the base tag its throwing the following javascript error:

window.opener.document is null or not an object can you suggest me why its
happening and how can i correct this?

I will be really thankfull to you for your knowldge sharing with me to solve
my problem.
 
E

Eliyahu Goldin

Hitesh,

Just add

<base target=_self>

in the <head> section of your dialog.

Eliyahu
 
G

Guest

Hi Eliyahu,

You are absolutely correct after posting the question i was also trying the
same and it worked.

lot of thanks for your suggestions in solving my problem.
 
E

Eliyahu Goldin

Are you trying to pass values back from the dialog to the parent window? You
can encapsulate whatever you want to pass back into one javascript object
and pass it back in window.returnValue. The parent will receive it is a
result of your showModalDialog call.

Eliyahu
 

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

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top