locked
How to pop up another aspx in a modern browser? RRS feed

  • Question

  • User366448803 posted

    I have some old code that works fine in IE11, but any modern browser it will not work.  The web page itself has a lot of data on it using an ItemTemplate with a Table and data from a Database query.  

    When the page loads, the code is checking IsPostback:

    • NO Postback:  setTimeout to 60000 (to refresh the screen, update DB data). 
    • IS Postback:  Checks the database to see if an "alert" has happened (From an alert table in the DB).  If it has an alert, then it will load the Alarms.aspx page using the code below.

    If myAlarm.Rows.Count > 0 then

       dim strURL as string = Alarm.aspx?ID=" & myAlarm.Rows(0).Item(0)

       ClientScript.RegisterStartupScript(GetType(Page), "Alarm", "<script language='javascript'>window.showModalDialog('" & strUrl & "',null,'dialogWidth=460px;dialogHeight=310px;status=no;resizable=yes;');document.frmAlog.submit();</script>")

    This works fine on IE11, but they are moving to Chrome and it does not work.  Now, I am aware that showModalDialog no longer works in modern browsers, but I tried window.open and that did not work either.  I'm fine restructuring the code, but the problem is this:

    Popup Page (Alarm.aspx)

    1.  Takes a parameter
    2.  Loads the alarm information from the database into multiple fields
    3.  User has to interact with combo-boxes (which operate interactively based upon selection)
    4. User has to submit the data

    This essentially means there are quite a few postbacks to Alarm.aspx itself, if that matters.

    Any ideas how I accomplish this?

    Thursday, April 22, 2021 7:00 PM

All replies

  • User-1545767719 posted

    I suggest that you use a user control instead of the alarms.aspx and the modalpopup extender of Ajax Conttol Toolkit.

    Thursday, April 22, 2021 10:34 PM
  • User1535942433 posted

    Hi CovingtonFF,

    It is very possible that the popup window is blocked by Google Chrome, because it will show automatically in the page load. Google Chrome does not know that the popup window is legal or not. Please see Page tools: Pop-ups.

    To overcome the issue, an easy way is avoiding the popup. Try redirection instead:

    Response.Redirect("Alarms.aspx");

    Another way will be a bit more complex. We can handle the button's onclick event via JavaScript, call web method, and finally show the popup window. All these are done via JavaScript, so the page is not refreshing. Since the popup window is showed by JavaScript onclick handler function, Google Chrome might treat it as a legal window. For more information about how to call page method via JavaScript, please see Exposing Web Services to Client Script.

    Best regards,

    Yijing Sun

    Friday, April 23, 2021 5:10 AM