user1691243
user1691243

Reputation: 21

WebBrowser Close event without message

I'm making a Facebook share in C#, but when i share a link the Facebook force close the Window and shows the message: "The webpage you are viewing is trying to close the window. Do you want to close it?".

How can i remove this message?

I already tried this: Catching and handling Web Browser Close Event but don't work.

My code to share is:

public void doShare(string url)
    {
        string shareURL = "http://www.facebook.com/sharer/sharer.php?u=" + url;
        wb.Navigate(shareURL);
        while (wb.ReadyState != WebBrowserReadyState.Complete)
        {
            Application.DoEvents();
        }
        wb.Document.GetElementById("u_0_0").InvokeMember("click");
    }

Upvotes: 1

Views: 1941

Answers (1)

EricLaw
EricLaw

Reputation: 57075

Catch the WindowClosing event, set the Cancel flag to true, and then simply close your form yourself.

Upvotes: 1

Related Questions