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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to get the innerHtml from iframe in C# ?

how to get the innerHtml from iframe in C# ?

Scheduled Pinned Locked Moved C#
csharptutorialquestion
7 Posts 3 Posters 0 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.
  • K Offline
    K Offline
    kkun
    wrote on last edited by
    #1

    how to get the innerHtml from iframe in C# ? thanks ~

    N 1 Reply Last reply
    0
    • K kkun

      how to get the innerHtml from iframe in C# ? thanks ~

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      First you have to get document object for the IFRAME. Then Use innerHTML property to get it. See the following eg:

      var TxtEditor = document.getElementById('IFrameId').contentWindow.document;
      alert(TxtEditor.body.innerHTML)


      My Website | Ask smart questions

      K 1 Reply Last reply
      0
      • N N a v a n e e t h

        First you have to get document object for the IFRAME. Then Use innerHTML property to get it. See the following eg:

        var TxtEditor = document.getElementById('IFrameId').contentWindow.document;
        alert(TxtEditor.body.innerHTML)


        My Website | Ask smart questions

        K Offline
        K Offline
        kkun
        wrote on last edited by
        #3

        to [N a v a n e e t h]: thank you reply,but how did it in c# ?

        N L 2 Replies Last reply
        0
        • K kkun

          to [N a v a n e e t h]: thank you reply,but how did it in c# ?

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Make a hidden textbox run at server. Get IFRAME value using javascript, and assign to this textbox. Since your hidden textbox is a server control, you have access to it from code behind.


          My Website | Ask smart questions

          K 1 Reply Last reply
          0
          • K kkun

            to [N a v a n e e t h]: thank you reply,but how did it in c# ?

            L Offline
            L Offline
            lmoelleb
            wrote on last edited by
            #5

            Your question isn't clear enough! Are you hosting a web control in a WinForm application written in C#? Are you hosting a web control in a WPF application written in C#? Are you using C# as a client side scripting language in the browser? Are you writing an ASP.NET page in C# and want to see what the client has in the IFrame (nope, not possible, but it might still be what you are looking for so I included it)? Are you accessing a web server from C# and want to extract the HTML from the web server response? I am sure there are more possibilities, but this is what I could come up with as I typed, so you probably need to add some details on what you are doing and what you try to achieve.

            K 1 Reply Last reply
            0
            • N N a v a n e e t h

              Make a hidden textbox run at server. Get IFRAME value using javascript, and assign to this textbox. Since your hidden textbox is a server control, you have access to it from code behind.


              My Website | Ask smart questions

              K Offline
              K Offline
              kkun
              wrote on last edited by
              #6

              //Make a hidden textbox run at server. Get IFRAME value using javascript, and assign to this textbox. very good ~ but ,it also have problems ~ I have got the method that get value of iframe and assigned it to TextBox, but when run the method to do this ? it required a Event,a suitable Event,the Iframe haven't got those Events,for example:onkeyup,onkeydwon,onchange,onpropertychange...,and in this section it haven't got a

              or the other control like to occur. In other way , there's a user control with two properties:Text and Content. when using the user control ,we just see the Content property is ok , the Content property's value is the iframe's innerHtml,Now i know how to get innerHtml in javascript ,but i don't know how to use it in codebehind ?! the former said "..and assign to this textbox...",It request a suitable Event to do that , for there's no Form label,No button , only a button is in another page that use the user control,when it clicked we must show the user control's property ~ how ever , I do not like this method... thank you very much !

              1 Reply Last reply
              0
              • L lmoelleb

                Your question isn't clear enough! Are you hosting a web control in a WinForm application written in C#? Are you hosting a web control in a WPF application written in C#? Are you using C# as a client side scripting language in the browser? Are you writing an ASP.NET page in C# and want to see what the client has in the IFrame (nope, not possible, but it might still be what you are looking for so I included it)? Are you accessing a web server from C# and want to extract the HTML from the web server response? I am sure there are more possibilities, but this is what I could come up with as I typed, so you probably need to add some details on what you are doing and what you try to achieve.

                K Offline
                K Offline
                kkun
                wrote on last edited by
                #7

                in one word , In a UserControl ,How to get a iframe's innerHtml value and assign to its property ?

                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