none
Disable Prompts within WebBrowser Control RRS feed

  • Question

  • I am displaying a Dynamics CRM Lookup page within a WebBrowser control in my winform. When the user selects a record within that page and click 'Ok', it displays a security warning message:

    "The webpage you are viewing is trying to close the window.

    Do you want to close the window?

    Yes  No"

    I am using MSHTML to wire up an handler on Window.Unload event like so:

    _doc2 = _wb.Document.DomDocument as mshtml.IHTMLDocument;
    
                    if (_doc2 != null)
                    {                    ((mshtml.HTMLDocumentEvents2_Event)_doc2).onclick += new HTMLDocumentEvents2_onclickEventHandler(SetRegarding_OnClick);
                        _wb.Document.Window.Unload += new HtmlElementEventHandler(Window_Unload);
                    }

    And on the handler itself, I try to pass a bool "true" to indicate the window needs to be closed but to no avail. 

            private void Window_Unload(object sender, HtmlElementEventArgs args)
            {
                args.ReturnValue = true;
            }

    Apparently, the security warning pops up before it fires up any other event. I need to be able to make sure that the pop up is disabled and the form is closed on click of Ok. How do I accomplish this functionality?

    Thanks.

    Wednesday, October 9, 2013 6:15 PM

Answers