473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

WebBrowser and HTML capture (ignore previous)

Sorry, I attempted to tab in the previous post and accidentally posted
prematurely.

I am trying to use the WebBrowser control from Visual Studio 2005 to load a
web page and display its HTML content in a text box on a Form of a Windows
Application. I have a button on the Form that invokes the following code
when clicked:

webBrowser1.Url = new Uri("http://www.microsoft.com");
textBox1.Text = webBrowser1.DocumentText;

However, this does not work because the page does not actually load until
the button click method has returned. To actually load and display the page,
I have to click the button twice and do this:

if (toggle == 0)
{
webBrowser1.Url = new Uri("http://www.microsoft.com");
toggle = 1;
}
else
{
textBox1.Text = webBrowser1.DocumentText;
toggle = 0;
}

I want to capture the page contents with a single button click, but I
suspect I will have to do something in a thread or use invoke or something.
Can someone give me an example of how to do this?

Thanks in advance,
Don
Nov 17 '05 #1
2 7936
Don,

What I would do is create an event handler for the DocumentCompleted
event, and when that event is fired, set the text to the source. It
wouldn't prevent the button from being clicked twice, but it wouldn't matter
that much, since it would just cause the page to be reloaded, and the event
to be fired again (the state wouldn't be corrupted).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Don Tucker" <Do*******@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
Sorry, I attempted to tab in the previous post and accidentally posted
prematurely.

I am trying to use the WebBrowser control from Visual Studio 2005 to load
a
web page and display its HTML content in a text box on a Form of a Windows
Application. I have a button on the Form that invokes the following code
when clicked:

webBrowser1.Url = new Uri("http://www.microsoft.com");
textBox1.Text = webBrowser1.DocumentText;

However, this does not work because the page does not actually load until
the button click method has returned. To actually load and display the
page,
I have to click the button twice and do this:

if (toggle == 0)
{
webBrowser1.Url = new Uri("http://www.microsoft.com");
toggle = 1;
}
else
{
textBox1.Text = webBrowser1.DocumentText;
toggle = 0;
}

I want to capture the page contents with a single button click, but I
suspect I will have to do something in a thread or use invoke or
something.
Can someone give me an example of how to do this?

Thanks in advance,
Don

Nov 17 '05 #2
That was easy and did the trick. Thanks!
Don

"Nicholas Paldino [.NET/C# MVP]" wrote:
Don,

What I would do is create an event handler for the DocumentCompleted
event, and when that event is fired, set the text to the source. It
wouldn't prevent the button from being clicked twice, but it wouldn't matter
that much, since it would just cause the page to be reloaded, and the event
to be fired again (the state wouldn't be corrupted).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Don Tucker" <Do*******@discussions.microsoft.com> wrote in message
news:CF**********************************@microsof t.com...
Sorry, I attempted to tab in the previous post and accidentally posted
prematurely.

I am trying to use the WebBrowser control from Visual Studio 2005 to load
a
web page and display its HTML content in a text box on a Form of a Windows
Application. I have a button on the Form that invokes the following code
when clicked:

webBrowser1.Url = new Uri("http://www.microsoft.com");
textBox1.Text = webBrowser1.DocumentText;

However, this does not work because the page does not actually load until
the button click method has returned. To actually load and display the
page,
I have to click the button twice and do this:

if (toggle == 0)
{
webBrowser1.Url = new Uri("http://www.microsoft.com");
toggle = 1;
}
else
{
textBox1.Text = webBrowser1.DocumentText;
toggle = 0;
}

I want to capture the page contents with a single button click, but I
suspect I will have to do something in a thread or use invoke or
something.
Can someone give me an example of how to do this?

Thanks in advance,
Don


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carl Manson | last post by:
Hi All, I am writing a complex print job solution that requires the printing of many HTML documents in an exactly defined order. Our application uses the IE WebBrowser control to render the...
9
by: ASP .NET Newbie | last post by:
How can I run a WebBrowser control using ASP.NET/VB.NET? I know I can use the WebClient to get the page data, but I need to be able to use the WebBrowser (AxWebBrowser)? Thanks, Chad
0
by: Vin | last post by:
The .Net 2.0's webbrowser is neat and pretty. But I am not able to capture Key events when the focus is on the webbrowser control in my winform. Options tried. 1. Wrote a class which extends this...
8
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
4
by: ejder | last post by:
I am writing a program. I am using webbrowser. I implement webbrowser but I need to capture posted data from webbroser . soo when I visiting site on my webbrowser , For example I enter membership...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
0
by: =?Utf-8?B?c25naWxi?= | last post by:
I am having 3 issues with the WebBrowser control which may all be related. The HTML for the page is the standard Weather Magnet from weather.com. The actual HTML is at the bottom of this page. ...
2
by: =?Utf-8?B?c25naWxi?= | last post by:
The WebBrowser control is described as exposing numerous public mouse events. See: http://msdn2.microsoft.com/en-us/library/ayestehw.aspx. many of the event are described as: "This event is not...
4
by: Robson Siqueira | last post by:
Folks, I am facing a problem. I am trying to manipulate the HTML data (thru the Document and DocumentText properties) of the WebBrowser object (System.Windows.Forms). The problem is that the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.