locked
window.open not working with ScriptManager.RegisterStartupScript RRS feed

  • Question

  • User1281245994 posted

    I injected a javascript block as follows..

    StringBuilder sb1 = new StringBuilder();
    sb1.Append("window.open('DMS/DMSHome.aspx','DMS:::','');");
    ScriptManager.RegisterStartupScript(Page, typeof(Page), "mydialog", sb1.ToString(), true);

    In this page there is no AJAX scriptmanager but I used ScriptManager.RegisterStartupScript which was working fine till yesterday. From today morning it stopped working in IE as well as in Google chrome. Where as alert messages using ScriptManager.RegisterStartupScript is working fine. Problem is only where I was opening a new window.

    Then I changed the code and used 

    Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('DMS/DMSHome.aspx','_newtab','left=100,top=20,width=1000,height=590');", true);

    which is working fine.

    Can anybody tell me what really happened so that window.open stopped working in ScriptManager.RegisterStartupScript

    Monday, July 21, 2014 3:03 AM

Answers

  • User-760709272 posted

    Things don't suddenly stop working.  Look at the history of any source control you're using to see changes that have been made, maybe by other people.  Failing that an update or something will have gone on.  The percentage of times someone has told me that code has stopped working despite the fact that nothing has changed, that turned out to be a change they made but "forgot about" or "didn't think it would make a difference", or "yeah I updated the framework from this to that" or "Yeah, I unistalled that package" is 100%.

    You don't need an AJAX Script manager on the page to use ScriptManager but it is intended for either the ajax script manager or the normal scriptmanager.  If you don't have a scriptmanager you use ClientScript, so your code is behaving as it is designed to.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 21, 2014 4:54 AM

All replies

  • User-760709272 posted

    Things don't suddenly stop working.  Look at the history of any source control you're using to see changes that have been made, maybe by other people.  Failing that an update or something will have gone on.  The percentage of times someone has told me that code has stopped working despite the fact that nothing has changed, that turned out to be a change they made but "forgot about" or "didn't think it would make a difference", or "yeah I updated the framework from this to that" or "Yeah, I unistalled that package" is 100%.

    You don't need an AJAX Script manager on the page to use ScriptManager but it is intended for either the ajax script manager or the normal scriptmanager.  If you don't have a scriptmanager you use ClientScript, so your code is behaving as it is designed to.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 21, 2014 4:54 AM