Web Browser control - How to make input fields editable?
In my windows form i have created a web browser control (AxSHDocVw). I want to grab user's actions like
1- what links he clicks
2- what information he enteres in the textbox and
3- what text he selects from anywhere from the rendered page.
The problem is that the text boxes are not editable. I mean user can not enter or select any text from them. I guess i am missing some minor thing.
Please have a look at the necessary code here:
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using mshtml;
using MsHtmHstInterop;
using AxSHDocVw;
[Serializable]
public class HtmlUIForm : Form, IDocHostUIHandler
{
protected AxWebBrowser WebBrowser;
public HtmlUIForm()
{
InitializeComponent();
this.WebBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(th is.WebBrowser_DocumentComplete);
object flags = 0;
object targetFrame = String.Empty;
object postData = String.Empty;
object headers = String.Empty;
this.WebBrowser.Navigate("about:blank", ref flags, ref targetFrame, ref postData, ref headers);
ICustomDoc cDoc = (ICustomDoc)this.WebBrowser.Document;
cDoc.SetUIHandler((IDocHostUIHandler)this);
this.WebBrowser.Navigate("https://login.yahoo.com/config/login_verify2?&.src=ym", ref flags, ref targetFrame, ref postData, ref headers);
}
private void WebBrowser_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
IHTMLDocument2 doc = (IHTMLDocument2)this.WebBrowser.Document;
HTMLButtonElement button = (HTMLButtonElement)doc.all.item("theButton", null);
((HTMLButtonElementEvents2_Event)button).onclick += new HTMLButtonElementEvents2_onclickEventHandler(this. Button_onclick);
}
private bool Button_onclick(IHTMLEventObj e)
{
MessageBox.Show("Alert from the app: Received theButton.onclick!");
return true;
}
[STAThread]
static void Main(string[] args)
{
Application.Run(new HtmlUIForm());
}
}
__________________
BaburMan
|