Hongye Sun

A world of .NET
posts - 3, comments - 1, trackbacks - 0

My Links

News

Article Categories

Archives

Post Categories

Submit button unexpected postback in WebBrowserControl

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.

Print | posted on Thursday, March 26, 2009 11:21 AM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: