Geeks With Blogs
Hongye Sun

In .NET, When you add an event handler to any of the predefined events in HtmlDocument of WebBrowserContro.Document, it will register a default event handler for all the other events. 

If the submit button has an onclick javascript event handler. The javascript returns false to prevent the page to postback. However, return false will not work properly if there is another event handler registered. Instead of returning false, the best choice in the HTML page is to set event.returnValue = false.

Another workaround is to change your .NET code, use AttachEventHandler method instead:

Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
    doc = webBrowserControl.Document  
    doc.AttachEventHandler("onclick"AddressOf oDoc.OnClick)  
End Sub 

Remove Handles doc.Click in your code.
Posted on Thursday, March 26, 2009 11:21 AM | Back to top

Comments on this post: Submit button unexpected postback in WebBrowserControl

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © hongyes | Powered by: