473,383 Members | 1,862 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,383 software developers and data experts.

how do I input costum content into the Winforms.WebBrowser?

Hi NewsGroup

Hope you can help me with this. I'm using the
"System.Windows.Forms.WebBrowser" to display a various markuplanguage. And
it works fine pointing the "WebBrowser.Url" to a local or remote uri. But
what I would actually like to do, is to download a webpage as a string,
analyze it, possibly modify it, and then display it on the WebBrowser -
without asking the WebBrowser to download it again. By the "HttpWebRequest"
I can easily retrieve the textual webpage and I assume you could replace the
"WebBrowser.document" with a new "Forms.HtmlDocument", made of the textual
webpage just downloaded. But I cant seem to make it work - how do I create a
new HtmlDocument from a string - that may or may not be wellformed!?

any tips most warmly welcomed

../ask
Nov 17 '05 #1
5 2878
The easiest way to do this involves saving the content to a file, and
then having the webbrowser navigate to that file. The problem with this is
that any relative links in the document will be resolved with the file path
as the base url, and not the source where it came from.

If you need to resolve these links to the url that you downloaded the
content from, then you will need to do some work. I find that the easiest
way is to create an implementation of IMoniker, which will return the
contents through an IStream implementation. You can have your
GetDisplayName method of your implementation return the URL that the
document originally came from.

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

"ask josephsen" <jaj(((a)))oticon.dk> wrote in message
news:42**********************@news.dk.uu.net...
Hi NewsGroup

Hope you can help me with this. I'm using the
"System.Windows.Forms.WebBrowser" to display a various markuplanguage. And
it works fine pointing the "WebBrowser.Url" to a local or remote uri. But
what I would actually like to do, is to download a webpage as a string,
analyze it, possibly modify it, and then display it on the WebBrowser -
without asking the WebBrowser to download it again. By the
"HttpWebRequest" I can easily retrieve the textual webpage and I assume
you could replace the "WebBrowser.document" with a new
"Forms.HtmlDocument", made of the textual webpage just downloaded. But I
cant seem to make it work - how do I create a new HtmlDocument from a
string - that may or may not be wellformed!?

any tips most warmly welcomed

./ask

Nov 17 '05 #2
No need to save to file, you can manipulate your html in memory and
then just send it to an Internet Explorer browser, see here
http://spaces.msn.com/members/pjsson/Blog/cns!1p76K4WF1ADMWttSKAc6E-Sg!117.entry

/Patric
My C# blog: http://spaces.msn.com/members/pjsson/

Nov 17 '05 #3
Patric,

This will work, but it won't address the issue with having to resolve
relative references in the document.

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

"Patric J" <pa******@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
No need to save to file, you can manipulate your html in memory and
then just send it to an Internet Explorer browser, see here
http://spaces.msn.com/members/pjsson/Blog/cns!1p76K4WF1ADMWttSKAc6E-Sg!117.entry

/Patric
My C# blog: http://spaces.msn.com/members/pjsson/

Nov 17 '05 #4
No of course not since your webpage is not hosted by the webserver you
pulled it from anymore. Just add a base href to the html string like
this, replace [ and ] with < and >

[base href="http://spaces.msn.com/members/pjsson/"]

[a href="Blog/cns!1p76K4WF1ADMWttSKAc6E-Sg!117.entry">Injecting HTML
code
directly into an Internet Explorer</a]

Nov 17 '05 #5

Thank you both very much for the imput.

I assume it is not possible to create a "Forms.HtmlDocument" from a string
which is not welformed?

../ask

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ol**************@TK2MSFTNGP10.phx.gbl...
The easiest way to do this involves saving the content to a file, and
then having the webbrowser navigate to that file. The problem with this
is that any relative links in the document will be resolved with the file
path as the base url, and not the source where it came from.

If you need to resolve these links to the url that you downloaded the
content from, then you will need to do some work. I find that the easiest
way is to create an implementation of IMoniker, which will return the
contents through an IStream implementation. You can have your
GetDisplayName method of your implementation return the URL that the
document originally came from.

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

"ask josephsen" <jaj(((a)))oticon.dk> wrote in message
news:42**********************@news.dk.uu.net...
Hi NewsGroup

Hope you can help me with this. I'm using the
"System.Windows.Forms.WebBrowser" to display a various markuplanguage.
And it works fine pointing the "WebBrowser.Url" to a local or remote uri.
But what I would actually like to do, is to download a webpage as a
string, analyze it, possibly modify it, and then display it on the
WebBrowser - without asking the WebBrowser to download it again. By the
"HttpWebRequest" I can easily retrieve the textual webpage and I assume
you could replace the "WebBrowser.document" with a new
"Forms.HtmlDocument", made of the textual webpage just downloaded. But I
cant seem to make it work - how do I create a new HtmlDocument from a
string - that may or may not be wellformed!?

any tips most warmly welcomed

./ask


Nov 17 '05 #6

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

Similar topics

1
by: jen92103 | last post by:
HI, I want to add the "Did you mean" - Google feature to searches on my website. My website lets users search for a business using different parameters. If there is no match, I want to do a...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
1
by: Jim Fox | last post by:
I have an .MHT file which I would like to display in a WebBrowser control. This should be pretty simple, since I can open the MHT file in IE without a problem. However, I cannot seem to find a way...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: Cecil Westerhof | last post by:
I have the following code in a xslt-file: <xsl:template match="outputfield"> <xsl:for-each select='.'> <tr> <td class = "inputDescription"><xsl:value-of select='.' />:</td> <td><input class =...
11
by: C.W.Holeman II | last post by:
I what to hide an input element and the following text. I have the selector for the input working and just need to grab the text following it. CSS: form{ display:table; text-align:center; }
2
by: JDeats | last post by:
Using VS.NET 2005, if you place a WinForms WebBrowser control on a form, then place a command button on that form and in the "click" even handler for the command you do: webBrowser1.DocumentText...
11
by: Frank Rizzo | last post by:
I have a WebBrowser control on a .net 2.0 winforms app. I load up a page and want to get the selected entry of a dropdown. I can get the element: HtmlElement stationList =...
0
by: smithse | last post by:
Hello All, This is my very first posting on bytes!! Here's my "challenge": I have a winforms app (vb.net - 2008) that has a form with the webbrowser control (ie) on it. The page which I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.