How does WebBrowser obtain submitted data?
WebBrowser is actually an encapsulation of the ActiveX control SHDocVw, and many underlying calls of this SHDocVw WebBrowser control are not provided for implementation. You need to directly operate the SHDoceVw Control for this application. The procedure is as follows:
1. Find the dynamic library shdocvw. dll in the windows/system32 directory and add it to the reference.
2. Add the following statement to Form1_Load:
SHDocVw. WebBrowser wb = (SHDocVw. WebBrowser) webBrowser1.ActiveXInstance;
Wb. BeforeNavigate2 + = new DWebBrowserEvents2_BeforeNavigate2EventHandler (WebBrowser_BeforeNavigate2 );
3. Add the following member functions
Private void WebBrowser_BeforeNavigate2 (object pDisp, ref object URL, ref object Flags,
Ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
String postDataText = System. Text. Encoding. ASCII. GetString (PostData as byte []);
}
After completing the preceding three steps, you will respond to the BeforeNavigate2 event when you post data,
PostDataText contains your post data.
WebBrowser is a VB Control made by the IE kernel.
SHDocVw is a Common Language Runtime Library.
Webbrowser. Navigate connects to the specified URL and displays the webpage. It is equivalent to a navigation webpage.