Page view counter

Browser close after logout

Last post 08-08-2008 12:22 PM by budugu. 4 replies.

Sort Posts:

  • Browser close after logout

    08-08-2008, 10:41 AM
    • Loading...
    • snailpace
    • Joined on 05-28-2008, 4:48 PM
    • Posts 154
    • Points 21

    I have a logout button in my page. When a user clicks on that button, I have to close the browser. How do I achieve this in VB.NET?

    THanks

  • Re: Browser close after logout

    08-08-2008, 10:47 AM
    Answer
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 13,275
    • Points 71,391

    VB.NET cannot close the browser. A JavaScript function call would need to do that.

    With an HTML button:
    <input type="button" onclick="window.close();" value="Close" />

    With an ASP:Button:
    <asp:button id="closeButton" runat="server" text="Close" OnClientClick="window.close(); return false;"></asp:button>

    NC...

  • Re: Browser close after logout

    08-08-2008, 10:53 AM
    • Loading...
    • budugu
    • Joined on 01-12-2006, 2:15 PM
    • North Carolina
    • Posts 2,711
    • Points 17,542

    Try this code.. 

    Response.Write("<script language='javascript'> { window.opener = window;window.close();}</script>")  ' It is NOT recommended to write js like this
    
     
    My Blog


    "Don't be afraid to be wrong; otherwise you'll never be right."
  • Re: Browser close after logout

    08-08-2008, 10:56 AM
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 13,275
    • Points 71,391

    budugu:

    Try this code.. 

    Response.Write("<script language='javascript'> { window.opener = window;window.close();}</script>")  ' It is NOT recommended to write js like this
    

     

    Why would you possibly use Response.Write to output script?

    NC...

     

  • Re: Browser close after logout

    08-08-2008, 12:22 PM
    • Loading...
    • budugu
    • Joined on 01-12-2006, 2:15 PM
    • North Carolina
    • Posts 2,711
    • Points 17,542

    Yes, It is NOT recommended .

    My Blog


    "Don't be afraid to be wrong; otherwise you'll never be right."
Page 1 of 1 (5 items)