none
HTML CODE in WEbBrowser control

    Question

  • Hi

    I have a HTML COde in a string
    I Need to Directly assign the code to Webbrowser control so that the page is dispalyed.

    Now I am writing tht code to a HTML file in Disk and giving the location of that file to the webbrowser control

    axWebBrowser1.Navigate(Application.StartupPath+"\\SuperseededResults.htm",ref Optional,ref Optional,ref Optional,ref Optional);

    if i can find out a solution to this i can avoid writing to disk and then loading.

    Pls Help me out

    Thanks
    Vidhyaprakash

    Thursday, December 22, 2005 6:46 AM

Answers

  • reference mshtml in your project

    navigate to about:blank

    then use the DOM to build elements. . .

    axWebBrowser1.Navigate("about:blank");

    mshtml.HTMLDocument doc = axWebBrowser1.Document as mshtml.HTMLDocument;

    mshtml.HTMLBody body = doc.createElement("body") as mshtml.HTMLBody;

    body.innerHTML = "this is some <em>quick</em> and <b>dirty</b> <u>dynamic</u> html";

    doc.appendChild(body as mshtml.IHTMLDOMNode);

    Thursday, December 22, 2005 11:02 AM
    Moderator

All replies

  • reference mshtml in your project

    navigate to about:blank

    then use the DOM to build elements. . .

    axWebBrowser1.Navigate("about:blank");

    mshtml.HTMLDocument doc = axWebBrowser1.Document as mshtml.HTMLDocument;

    mshtml.HTMLBody body = doc.createElement("body") as mshtml.HTMLBody;

    body.innerHTML = "this is some <em>quick</em> and <b>dirty</b> <u>dynamic</u> html";

    doc.appendChild(body as mshtml.IHTMLDOMNode);

    Thursday, December 22, 2005 11:02 AM
    Moderator
  •  

    Hi should i need to add any other reference  for mshtml?

    pls tell me in which name space its in

    Thursday, December 22, 2005 11:18 AM
  • oops. . . sorry that was for 1.1.

    here this should work (Using the 2.0 native System.Windows.Forms.WebBrowser control and referencing mshtml)

    webBrowser1.Navigate("about:blank");

    HtmlDocument doc = webBrowser1.Document;

    mshtml.HTMLDocument domdoc = doc.DomDocument as mshtml.HTMLDocument;

    mshtml.HTMLBody body = domdoc.createElement("body") as mshtml.HTMLBody;

    body.innerHTML = "this is some <em>quick</em> and <b>dirty</b> <u>dynamic</u> html";

    domdoc.appendChild(body as mshtml.IHTMLDOMNode);

     

     

    By the way. . .  how does one create code tags in forum posts now???

    Whats the deal with the forced <P> ???

    Thursday, December 22, 2005 2:35 PM
    Moderator