How to disable onbeforeunload event

Last post 05-09-2008 11:07 AM by NC01. 2 replies.

Sort Posts:

  • How to disable onbeforeunload event

    05-08-2008, 10:54 PM
    • Loading...
    • gridview
    • Joined on 07-06-2006, 9:34 PM
    • Posts 277

    Not able to click on hyperlink without seeing a warning message fired by "onbeforeunload event".  Please suggest. Below are the details.

    Thanks.

    I am using <td><a id="profileLink" runat="server">View Profile</a></td>

    which opens a popup to show profile based on usersID, I am setting the "OnClick" propert at the server side as :

     

    1    profileLink.HRef = "#"
    2    
    3    profileLink.Attributes.Add("onclick", "ShowPopup('ShowProfile.aspx?UserId=" & 1 & "');return false;NoPrompt();")
    4    
    

     

    I used NoPrompt() to disable the firing of the javascript function "confirmExit" which is called by "onbeforeunload event" as below to warn user if they want to leave the page without save.

    NoPrompt javascript function sets the flag to false so that confirmExit doesnot warn user when user  click "View Profile link"

    window.onbeforeunload = confirmExit;

  • Re: How to disable onbeforeunload event

    05-09-2008, 6:20 AM
    • Loading...
    • blodfox777
    • Joined on 07-12-2007, 12:30 PM
    • Posts 64

    Hi gridview

    I think you dont need to disable the onbeforeunload event

    just write a 'if/else' in confirmExit(), to judge whether the Popup should to show.

    Regards!
    Lance
    -- "Mark As Answer" If my reply helped you --
  • Re: How to disable onbeforeunload event

    05-09-2008, 11:07 AM
    Answer
    • Loading...
    • NC01
    • Joined on 08-26-2005, 7:33 PM
    • Posts 6,886
    • TrustedFriends-MVPs

    I just posted a solution for something very similar here: http://forums.asp.net/t/1259060.aspx

    Also when using ShowPopup('ShowProfile.aspx?UserId=" & 1 & "');return false;NoPrompt(); The NoPrompt function will NEVER be called since you are executing a return beforehand.

    NC...

Page 1 of 1 (3 items)