window.open & RegisterClientScriptBlock

G

Guest

Hello,

I try to open a new Window in code behind with :
ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.open('toto.doc');", true);

My problem is that the new window is created but it disappears immediatly
just after creation!!

For information, I tried this:

ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.location=''toto.doc';", true);

IE7 ask me to validate the download in the top of the browser (it is a
security message that we have to validate to continue...)

I tried also this:

ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.open(Image.jpg');", true);

I have a new Window with my image!

In fact, it doesn't work with files that need to have the validation message
(open, save to disk, cancel)

How can I download these kind of files ?

Thanks,

David.
 
N

nahid

Hello,

I try to open a new Window in code behind with :
ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.open('toto.doc');", true);

My problem is that the new window is created but it disappears immediatly
just after creation!!

For information, I tried this:

ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.location=''toto.doc';", true);

IE7 ask me to validate the download in the top of the browser (it is a
security message that we have to validate to continue...)

I tried also this:

ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.open(Image.jpg');", true);

I have a new Window with my image!

In fact, it doesn't work with files that need to have the validation message
(open, save to disk, cancel)

How can I download these kind of files ?

Thanks,

David.

hi,
try this from code behind hope help

//Set the appropriate ContentType.
Response.ContentType = "Application/doc";
//Get the physical path to the file.
string FilePath = MapPath("s.doc");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();

nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
 
G

Guest

Hi,

Sorry but I have an error message on my page :
The XML page can't be displayed ...

A bad caracter has been found in a text content...

More, I want to open a new window with the content file inside, not the the
page itself.

In fact, this code could work :
ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript",
"window.open('toto.doc');", true);

Maybe a parameter in IE7 to change ?
Why my new page begins to be displayed and disappears immediatly ?
Why does it work with a text file or an image file ?

Thanks in advance,
David.
 
G

Guest

In fact, I have to encode as "application/msword"

It works but I still want to create a new window...

If I use the code Response.WriteFile in a second webpage and I call it from
my startpage with RegisterClientScriptBlock and window.open, the problem is
still here!
I hear the sound like IE blocks a new popup window even if I authorize IE...

What can I do else?
Thanks.
 

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,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top