"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