Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. WebBrowser ?

WebBrowser ?

Scheduled Pinned Locked Moved C#
tutorialcsharphtmlcssdesign
6 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohammad Dayyan
    wrote on last edited by
    #1

    Hi. Is it possible to change content of a WebBrowser object in C# without using HTML files ? I mean : For example we have following XHTML code :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
    <style type="text/css">
    <!--
    body,td,th {
    color: #000;
    }
    body {
    background-color: #990;
    }
    -->
    </style></head>

    <body>
    <table width="100%" border="1">
    <tr>
    <td align="center">TEST01</td>
    <td align="center">test02</td>
    </tr>
    <tr>
    <td><p>test03</p></td>
    <td align="center">test04</td>
    </tr>
    </table>
    </body>
    </html>

    Now , I wanna show the design in WebBrowser => http://img143.imageshack.us/img143/6855/50068901.png[^] I would be appreciate if you guide me !

    C C 2 Replies Last reply
    0
    • M Mohammad Dayyan

      Hi. Is it possible to change content of a WebBrowser object in C# without using HTML files ? I mean : For example we have following XHTML code :

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Test</title>
      <style type="text/css">
      <!--
      body,td,th {
      color: #000;
      }
      body {
      background-color: #990;
      }
      -->
      </style></head>

      <body>
      <table width="100%" border="1">
      <tr>
      <td align="center">TEST01</td>
      <td align="center">test02</td>
      </tr>
      <tr>
      <td><p>test03</p></td>
      <td align="center">test04</td>
      </tr>
      </table>
      </body>
      </html>

      Now , I wanna show the design in WebBrowser => http://img143.imageshack.us/img143/6855/50068901.png[^] I would be appreciate if you guide me !

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I do believe you can set the HTML of the control. If you can't, you can always save this HTML locally and point the control to it.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      M 1 Reply Last reply
      0
      • C Christian Graus

        I do believe you can set the HTML of the control. If you can't, you can always save this HTML locally and point the control to it.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        M Offline
        M Offline
        Mohammad Dayyan
        wrote on last edited by
        #3

        Christian Graus wrote:

        I do believe you can set the HTML of the control.

        Could you please guide me , which method or property do it in WebBrowser ?

        OriginalGriffO 1 Reply Last reply
        0
        • M Mohammad Dayyan

          Christian Graus wrote:

          I do believe you can set the HTML of the control.

          Could you please guide me , which method or property do it in WebBrowser ?

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Try DocumentText[^] (Try having a look at the documentation some time - it realy is quicker than asking here...)

          No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          M 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Try DocumentText[^] (Try having a look at the documentation some time - it realy is quicker than asking here...)

            No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

            M Offline
            M Offline
            Mohammad Dayyan
            wrote on last edited by
            #5

            Thanks a lot my friend.

            1 Reply Last reply
            0
            • M Mohammad Dayyan

              Hi. Is it possible to change content of a WebBrowser object in C# without using HTML files ? I mean : For example we have following XHTML code :

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <html xmlns="http://www.w3.org/1999/xhtml">
              <head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
              <title>Test</title>
              <style type="text/css">
              <!--
              body,td,th {
              color: #000;
              }
              body {
              background-color: #990;
              }
              -->
              </style></head>

              <body>
              <table width="100%" border="1">
              <tr>
              <td align="center">TEST01</td>
              <td align="center">test02</td>
              </tr>
              <tr>
              <td><p>test03</p></td>
              <td align="center">test04</td>
              </tr>
              </table>
              </body>
              </html>

              Now , I wanna show the design in WebBrowser => http://img143.imageshack.us/img143/6855/50068901.png[^] I would be appreciate if you guide me !

              C Offline
              C Offline
              carlecomm
              wrote on last edited by
              #6

              it's possible to change content of a webbrowser object in c# by using a string; for example : private void WriteHtml(string s){ //stream to string MemoryStream ms = new MemoryStream(); try{ byte[] htmlcode = System.Text.Encoding.Default.GetBytes(s); ms.Write(htmlcode,0,htmlcode.Length); Stream dataStream = ms; //Position dataStream.Seek(0,0); if(axWb.Document!=null){ //to IStream (axWb.Document as UnsafeNativeMethods.IPersistStreamInit).Load(new UnsafeNativeMethods.ComStreamFromDataStream(dataStream)); } }finally{ ms.Close(); } }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups