>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
[quoted text clipped - 3 lines]
>
> 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/library/system.web.ui.clientscriptmanager.regis
terstartupscript.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 </form> element. If
you want the script to be placed directly after the opening <form> element
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');");

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
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)
> 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
[quoted text clipped - 9 lines]
>
> It is like I need it to do another postback to fire the script.
Gee - 13 Mar 2008 00:52 GMT
Thanks
It doesn't work. I am guessing because it is done server side.
> for this to work, the users will have to make your site trusted, and
> enable
[quoted text clipped - 18 lines]
>>
>> It is like I need it to do another postback to fire the script.