473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Redirection script

Gee
I have a form which I need to redirect to a file (could be PDF or Word)
which is on the clients local system but I am having touble getting it to
fire the javascript.

In the PageLoad if not a postback I do

string oFileScript = "<script language='javascript'>" +

"window.location='file:///" + fileName + "';</script>";

Page.RegisterStartupScript("OpenFile", openFileScript);

It is like I need it to do another postback to fire the script.

Mar 12 '08 #1
3 1065
"Gee" <so*******@somone.comwrote in message
news:uC**************@TK2MSFTNGP05.phx.gbl...
>I have a form which I need to redirect to a file (could be PDF or Word)
which is on the clients local system but I am having touble getting it to
fire the javascript.

In the PageLoad if not a postback I do

string oFileScript = "<script language='javascript'>" +
Firstly, that's deprecated syntax - use <script type="text/javascript">
instead or, better still, use the Boolean overload to have ASP.NET add the
script tags for you automatically:
http://msdn2.microsoft.com/en-us/lib...tupscript.aspx
Page.RegisterStartupScript("OpenFile", openFileScript);
Secondly, RegisterStartupScript takes either three or four parameters, not
two...

Thirdly, you're populating a string variable called oFileScript, but you're
not actually using it - oFileScript is not the same as openFileScript...
It is like I need it to do another postback to fire the script.
Also, be aware that RegisterStartupScript method places the JavaScript at
the bottom of the ASP.NET page right before the closing </formelement. If
you want the script to be placed directly after the opening <formelement
so that it executes before the rest of the form element, then you need the
RegisterClientScriptBlock method.

Try placing this in your Page_Load:

ClientScript.RegisterClientScriptBlock(GetType(), "topCode",
"alert('Top');");
ClientScript.RegisterStartupScript(GetType(), "bottomCode",
"alert('Bottom');");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Mar 12 '08 #2
for this to work, the users will have to make your site trusted, and enable
the file open. so you might as just redirect to the file and not use
javascript.

Response.Redirect("file:///" + fileName);
-- bruce (sqlwork.com)
"Gee" wrote:
I have a form which I need to redirect to a file (could be PDF or Word)
which is on the clients local system but I am having touble getting it to
fire the javascript.

In the PageLoad if not a postback I do

string oFileScript = "<script language='javascript'>" +

"window.location='file:///" + fileName + "';</script>";

Page.RegisterStartupScript("OpenFile", openFileScript);

It is like I need it to do another postback to fire the script.

Mar 12 '08 #3
Gee
Thanks

It doesn't work. I am guessing because it is done server side.

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:48**********************************@microsof t.com...
for this to work, the users will have to make your site trusted, and
enable
the file open. so you might as just redirect to the file and not use
javascript.

Response.Redirect("file:///" + fileName);
-- bruce (sqlwork.com)
"Gee" wrote:
>I have a form which I need to redirect to a file (could be PDF or Word)
which is on the clients local system but I am having touble getting it to
fire the javascript.

In the PageLoad if not a postback I do

string oFileScript = "<script language='javascript'>" +

"window.location='file:///" + fileName + "';</script>";

Page.RegisterStartupScript("OpenFile", openFileScript);

It is like I need it to do another postback to fire the script.


Mar 13 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: RX | last post by:
I try to use PHP to redirect to other page and failed. Please give me a help. Thanks. The script is: if($rows_num>0) { session_start(); session_register("userid");...
5
by: Jerry | last post by:
Hi All I would very much appreciate your help: I have two scripts alternating in the background triggering themselves mutually. Here is how: 1.) Script A does something and then calls Script...
1
by: slash | last post by:
Hi, I have a page on my website that is driven dynamically off of a database by a perl/cgi script. The page contents are essentially reports of the following url:...
8
by: Manu | last post by:
Hi there, I am using a perl script to generate this html page which just redirects users to my ftp server. The problem is I get a "page cannot be displayed" in IE 6.0 (haven't tried other...
3
by: Wazz Up | last post by:
Hi, I'm trying run an image slide show where the images rotate once each, then after the last image in the array has been displayed for the specified amount of time, a redirection to another...
15
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
7
by: Steph | last post by:
Bonjour, Je souhaite lancer une redirection vers un fichier php via SRC= dans une condition if (voir ci-dessous en bas du script) mais la redirection ne fonctionne pas. Par contre la condition...
2
by: John Drako | last post by:
I have a database with a lot of links. Every so often I run a script to verify if the URLs are still valid. I weed out the ones with the 404 response. However, many responses are of the 303 kind...
1
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID,...
4
by: Neil Gould | last post by:
Anthony Jones wrote: That it is awaiting user action. Since a While/Wend or some other on-going background activity of a script appears to provide exceptions to the above statement, your usage...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.