RegisterStartupScript problem

Discussion in 'ASP .Net Web Controls' started by Kaan Acar, Mar 17, 2005.

  1. Kaan Acar

    Kaan Acar Guest

    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..
    Kaan Acar, Mar 17, 2005
    #1
    1. Advertising

  2. Kaan Acar

    Greg Finzer Guest

    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());
    }

    --------------------------------
    From: Greg Finzer
    <a href="http://www.kellermansoftware.com">Kellerman Software</a>
    Greg Finzer, Dec 23, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian W
    Replies:
    1
    Views:
    2,918
    Yan-Hong Huang[MSFT]
    Jul 4, 2003
  2. bruce barker
    Replies:
    1
    Views:
    494
    Dave Stienessen
    Jul 31, 2003
  3. Mark
    Replies:
    1
    Views:
    552
    Natty Gur
    Oct 16, 2003
  4. Earl Teigrob

    Using Page.RegisterStartupScript in Class

    Earl Teigrob, Feb 3, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,510
    Earl Teigrob
    Feb 3, 2004
  5. HockeyFan
    Replies:
    1
    Views:
    4,301
    George Ter-Saakov
    Jul 20, 2007
Loading...

Share This Page