window.open v.s. asp.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • carlor

    window.open v.s. asp.net

    Hi there,

    I have a form that contains a link button. When the user clicks the link
    button I need to enable a couple of other buttons on the page and open a new
    browser window giving it focus (keeping it on top). I have most of it working
    but I can't get it all working. I can either have the window open and disable
    the buttons with the new window in the background, or I can have the new
    window in the foreground but not be able to disable the buttons. Here's why:

    In the pageLoad of the main form, I add an onclick attribute to the link
    button that creates the new browser window using window.open:

    lbLinkButton.At tributes.Add("o nclick", "var w=window.open(' " &
    "newPage.as px" & "'); w.focus();")

    When the user clicks on the link button, the window.open gets fired and then
    the link button's click event fires and I enable the other buttons on my
    page. The problem is that the new window appears on top for a brief period
    then disappears to the background (I assume when the rest of the code behind
    for the main form executes).

    I was able to get the new browser window to stay in the foreground by adding
    "return false" to the above attribute as in:

    lbLinkButton.At tributes.Add("o nclick", "var w=window.open(' " &
    "newPage.as px" & "'); w.focus(); return false;")

    The problem I now have with the return false is that execution doesn't
    return to the main form's code behind; the link button's click event never
    gets trapped.

    Does anyone know of a solution to this problem?


    Thanks,

    Carlo.
  • Damien

    #2
    Re: window.open v.s. asp.net

    carlor wrote:[color=blue]
    > Hi there,
    >
    > I have a form that contains a link button. When the user clicks the link
    > button I need to enable a couple of other buttons on the page and open a new
    > browser window giving it focus (keeping it on top). I have most of it working
    > but I can't get it all working. I can either have the window open and disable
    > the buttons with the new window in the background, or I can have the new
    > window in the foreground but not be able to disable the buttons. Here's why:
    >
    > In the pageLoad of the main form, I add an onclick attribute to the link
    > button that creates the new browser window using window.open:
    >
    > lbLinkButton.At tributes.Add("o nclick", "var w=window.open(' " &
    > "newPage.as px" & "'); w.focus();")
    >
    > When the user clicks on the link button, the window.open gets fired and then
    > the link button's click event fires and I enable the other buttons on my
    > page. The problem is that the new window appears on top for a brief period
    > then disappears to the background (I assume when the rest of the code behind
    > for the main form executes).
    >
    > I was able to get the new browser window to stay in the foreground by adding
    > "return false" to the above attribute as in:
    >
    > lbLinkButton.At tributes.Add("o nclick", "var w=window.open(' " &
    > "newPage.as px" & "'); w.focus(); return false;")
    >
    > The problem I now have with the return false is that execution doesn't
    > return to the main form's code behind; the link button's click event never
    > gets trapped.
    >
    > Does anyone know of a solution to this problem?
    >[/color]
    Could you not, instead of hooking into the onclick event, have the
    following within the button click event:

    Response.Regist erClientScriptB lock("PopNewWin dow","<script
    type=""text/javascript"">va r w=window.open(' newPage.aspx');
    w.focus();</script>")

    Which would then open the window after the postback has completed...

    Comment

    • carlor

      #3
      Re: window.open v.s. asp.net

      Hi Damien,

      Thanks for the reply but unfortunately it didn't work. The page did not
      open. BTW, I had to change from "Response" to "Page".

      Thanks,

      Carlo.

      "Damien" wrote:[color=blue]
      > Could you not, instead of hooking into the onclick event, have the
      > following within the button click event:
      >
      > Response.Regist erClientScriptB lock("PopNewWin dow","<script
      > type=""text/javascript"">va r w=window.open(' newPage.aspx');
      > w.focus();</script>")
      >
      > Which would then open the window after the postback has completed...[/color]

      Comment

      Working...