473,748 Members | 8,933 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 13989
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
2770
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
3419
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
24252
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
6582
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
1471
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
41022
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
1436
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
1188
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
8987
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9366
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
9316
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
9241
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
8239
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
6793
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
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2777
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.