473,698 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clearing WebBrowser contents

Hi Folks,

Wonder if you can help...

All I'm trying to do is load a couple of simple HTML pages (in memory)
into the WebBrowser control, one after the other. I don't seem to be
able to clear the contents of the WebBrowser before I show the next
page, they're appended one after the other.

I've got some really simple code:

private void Form1_Load(obje ct sender, System.EventArg s e)
{
Object o = null;
axWebBrowser1.N avigate("about: blank", ref o, ref o, ref o, ref o);
document = (IHTMLDocument2 ) axWebBrowser1.D ocument;
document.writel n("<h1>One</h2>");
}

private void button2_Click(o bject sender, System.EventArg s e)
{
document = (IHTMLDocument2 ) axWebBrowser1.D ocument;
document.clear( );
axWebBrowser1.R efresh();
document.writel n("<h1>Two</h1>");
}

Any suggestions, I'm being stupid, but I can't see why and I've spent
too long on this already.

Thanks Dudes.

John
Nov 15 '05 #1
2 13971
Hi JH,

This is a guess.

Try navigating to about:blank again in button2_Click..

Regards,
Fergus
Nov 15 '05 #2
"Fergus Cooney" <fi******@tesco .net> wrote in message news:<OV******* *******@TK2MSFT NGP11.phx.gbl>. ..
Hi JH,

This is a guess.

Try navigating to about:blank again in button2_Click..

Regards,
Fergus


Thanks Fergus, I tried that before. Just for reference the answer to
this one is "RTFM". :) The documentation states that this method isn't
implemented for IHTMLDocument2, and I should've used:

document.write( "");
document.close( );

Works fine.

Thanks again,
John
Nov 15 '05 #3

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

Similar topics

5
2768
by: Charles Law | last post by:
Sorry for the cross post, but I'm not sure who is best placed to answer this one. This is the most bizarre behaviour of MSHTML and streams. I have a WebBrowser control that contains nothing but some default HTML. I want to copy the document and modify it before saving it to disk. So, I clone the document like this:
5
817
by: William Payne | last post by:
How do you get rid the contents in a std::stringstream? I'm using one in a for loop to format some status messages which I print to the screen. The stringstream member function clear() only clears flags (bits) in the stream, right? I solved it by declaring the stringstream inside the loop body even though I have need of another stringstream just after the loop. So for each iteration the constructor of the stringstream will be executed. Is...
8
3406
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
24246
by: markshowell | last post by:
I'm trying to use the following code to clear the contents of the two worksheets named Unpaid and Payments and then locate the cell pointer for that worksheet in cell A1 - Worksheets("Unpaid").Cells.ClearContents Worksheets("Unpaid").Select Range("A1").Select Worksheets("Payments").Cells.ClearContents Worksheets("Payments").Select Range("A1").Select
5
6577
by: mabond | last post by:
Hi recently read a posting and reply about Excel processs still running after the Appliction.Quit was called. Thought I might be able to use the same (System.Runtime.InteropServices.Marshal.ReleaseComObject(exApplication)) to solve my problem but could not. Background : My app uses a WebBrowser control to display to the user the contents of an Excel spreadsheet.:
0
1469
by: Bob Bryan | last post by:
After adding a WebBrowser control to my form (VS 2005), and the following 2 lines of code to a click event: webBrowser1.Navigate(new Uri(NextURL)); String PageData = webBrowser1.DocumentText; After stepping through the code, noticed that PageData was empty. After the click event completed processing and exited, the web page was properly displayed in my form. After entering the click event a 2nd time and stepping around the Navigate...
1
41019
by: David Veeneman | last post by:
In .NET 2.0, how do I clear the contents of a web browser control? I'm using a WebBrowser control in a Windows Form app to display strings genrated by my application and formatted as HTML--I'm not using it to do any actual web browsing. I use 'webBrowser1.DocumentText = myText' to load an HTML string into the control. But I can't clear that text when I want to load a new string into the control.
3
1432
by: Zytan | last post by:
The Immediate Window is filled with debugging output from previous runs. Besides manually right clicking and clearing it, is there a programmatic way of doing this? Should I create and use a console window instead and put my debugging output there? What's the best way to show debugging information? Zytan
0
1184
by: Johnny Jörgensen | last post by:
Does anybody have a good idea of how to save the WebBrowser control's contents in a PDF file? You could have a PDF printer and simply use WebBrowser1.Print, but I need to know the filename afterwards, so that wouldn't work for me. Any other ideas? TIA, Johnny J.
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.