Closing a browser window with C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • furtiveferret
    New Member
    • Sep 2008
    • 3

    #1

    Closing a browser window with C#

    Hi, I have just been asked to take over a project with no prior knowledge of either .net or C#, so I apologise for what may be a rather basic question.

    In one case a browser page contains a GridView including one column set to a HyperLinkField, launching to a separate window (currently, target="_blank" ). The user has asked for the new window to be closeable with a button control or similar rather than just the X. This would be easy enough if it were launched as a javascript popup, but I have been told that javascript is not supported in this context and I would have to close with C# code. So far I have not been able to find any examples through googling (or other solutions). Can anyone help please?
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    You can't use server side code to manipulate a client side window.

    I don't know why anyone would tell you that you can't use javascript. You should be able to do it very simply.

    Comment

    • furtiveferret
      New Member
      • Sep 2008
      • 3

      #3
      Hi

      Sorry for the delay in response, but you were right, it was very straightforward :

      Code:
      function close_me(){
                  window.opener = null;
                  window.close();
              }
      invoked with OnClientClick against the control.

      Comment

      Working...