RegisterStartupScript problem

K

Kaan Acar

Hi ,

i am using vbscript to open word document in my web page.(web page
is written in c# )
The code snippet in below. This code is doing what i want.
however when i try
to go back opener page with internet explorer "Back" button this
function is working again and word document is opening so i could
not open my page again.Is there any solution to unregister or block
this script...

string redirect = "c:/NewFolder/xxx.doc";
script = "<SCRIPT language='vbScript'>"
+ " window.location=\"" + redirect + "\""
+ " '</SCRIPT>";
Page.RegisterStartupScript("__JS_OPENFILE",script);

thanks..
 
G

Greg Finzer

While you cannot unregister a script, you can re-register the script and
have the function do nothing. See the example code below. This could
turned on or off when PagePostBack == false.

if (turnOn == true)
{
sbAlertScript.Append("<script language='javascript'>\n");
sbAlertScript.Append("function ShowMessageOfTheDay()\n");
sbAlertScript.Append("{\n");
sbAlertScript.Append("alert(\"" + message + "\");\n");
sbAlertScript.Append("}\n");
sbAlertScript.Append("</script>\n");

Page.RegisterStartupScript("alertScript", sbAlertScript.ToString());
}
else
{
sbAlertScript.Append("<script language='javascript'>\n");
sbAlertScript.Append("function ShowMessageOfTheDay()\n");
sbAlertScript.Append("{\n");
sbAlertScript.Append("\n");
sbAlertScript.Append("}\n");
sbAlertScript.Append("</script>\n");
Page.RegisterStartupScript("alertScript", sbAlertScript.ToString());
}
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top