|
|
 |
| .NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the .NET Framework 2.0 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

November 5th, 2009, 07:15 AM
|
|
Authorized User
|
|
Join Date: May 2004
Location: Rawalpindi, -, Pakistan.
Posts: 68
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|

November 5th, 2009, 07:52 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 1,359
Thanks: 0
Thanked 31 Times in 31 Posts
|
|
Try using the WebBrowser control, which is built in to the .Net Framework.
__________________
/- Sam Judson : Wrox Technical Editor -/
|

November 6th, 2009, 11:30 AM
|
|
Authorized User
|
|
Join Date: May 2004
Location: Rawalpindi, -, Pakistan.
Posts: 68
Thanks: 0
Thanked 1 Time in 1 Post
|
|
It works. Thanks 
__________________
BaburMan
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |