Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2009, 07:15 AM
Authorized User
 
Join Date: May 2004
Posts: 73
Thanks: 0
Thanked 1 Time in 1 Post
Default 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
 
Old November 5th, 2009, 07:52 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Try using the WebBrowser control, which is built in to the .Net Framework.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 6th, 2009, 11:30 AM
Authorized User
 
Join Date: May 2004
Posts: 73
Thanks: 0
Thanked 1 Time in 1 Post
Default

It works. Thanks
__________________
BaburMan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Browser Control [email protected] C# 2005 1 January 9th, 2008 06:26 AM
Using web browser control in C#2.0 [email protected] C# 5 November 1st, 2007 12:01 PM
how to make Ultragrid editable ? remya_pn Pro VB 6 0 February 26th, 2007 06:55 AM
Web Browser Activex Control gdelucchi Access 0 February 20th, 2006 02:18 PM
web control not displaying in browser rj1406 ASP.NET 1.0 and 1.1 Basics 8 September 19th, 2004 05:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.