Monday, March 12, 2012

Webbrowser control.

Hi,
I'm using the webbrowser control in an aplication and i'm having a little problem closing the windows.

I'm using this code provided by Microsoft to open a new windows:

Private Sub WebBrowser_NewWindow2(ByVal sender As System.Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles WebBrowser1.NewWindow2

Dim frmWeb As frmWeb
frmWeb = New frmWeb

e.ppDisp = frmWeb.WebBrowser1.Application

frmWeb.Visible = True

End Sub

My problem is when a page calls the window.close() script, the page doesn't close. Only the webbrowser control disapears.
The closing code is:

Private Sub WebBrowser1_WindowClosing(ByVal IsChildWindow As Boolean, ByVal Cancel As Boolean)

If (IsChildWindow) Then
Cancel = True
Else
Cancel = False
End If

End Sub

Can someone please helo me.
Thanks.I'm sory to be pushing this to the top, but I really have to get this working and I can't find any resources about this problem on the Net.
Thanks again.
Can someone at least point me into some direction. I really need this and can't find anything on the Net.
Thanks again.
You're talking about windows forms when this is an asp.net forum (for web development). I suggest you try the vb.net forum on www.vbforums.com. You might get your answer there. I have used windows forms but I haven't used the web browser control I'm afraid so I can't help you.
I know. My application is all asp.net, I just would like to run it in a Windows Form with a WebBrowser control, and Cassini.

Everything is working great, but i just can't get the form window to close. Only the webbrowser closes and i get stuck with a empty form window.
Sorry if this is too obvious but in this code:-


Private Sub WebBrowser1_WindowClosing(ByVal IsChildWindow As Boolean, ByVal Cancel As Boolean)
If (IsChildWindow) Then
Cancel = True
Else
Cancel = False
End If
End Sub

Have you tried putting me.close after cancel=False (assuming this is when the browser is being allowed to close)?
Yes. I've tried it. I think the problem is that the function isn't beeing called.
If i do this:


Private Sub WebBrowser1_WindowClosing(ByVal IsChildWindow As Boolean, ByVal Cancel As Boolean)

Msgbox("Test")

End Sub

No message box appears. It look's like it is not handleing the "window.close()".
But this is how the code is on MSDN site.
*bump*
All you ASP.NET Masters. Someone must know how to fix this bug.
Please help me. I'me getting very desperate.
Thanks again.
I know i'm starting to get on someone's nerves, but i really need some help on this.
Thanks again.
Did you try on theWindows Forms forums?

0 comments:

Post a Comment