Retieve InnerHTML from an IFrame on the Server Side.

Discussion in 'ASP .Net' started by L Anthony Johnson, Nov 20, 2003.

  1. Has anyone had any success doing this. I have tried, but the InnerHTML
    property always comes back as an empty string.

    L Anthony Johnson
     
    L Anthony Johnson, Nov 20, 2003
    #1
    1. Advertising

  2. This information is not sent back to the server. You would have to use
    Javascript to place an IFrame's InnerHTML in an HTML Hidden Input tag and
    read it that way.

    Alex Papadimoulis

    "L Anthony Johnson" <> wrote in message
    news:uAiS$...
    > Has anyone had any success doing this. I have tried, but the InnerHTML
    > property always comes back as an empty string.
    >
    > L Anthony Johnson
    >
    >
     
    Alex Papadimoulis, Nov 20, 2003
    #2
    1. Advertising

  3. I am doing the following. However whenever the text in the IFRame (ifrHTML)
    has any type of formatting other than plaintext, the innerHTML is not
    returned.

    If I do a CTRL+B (bold) or CTRL+U (Underline) or any other formatting. The
    cmdSend_Click routine is not entered. That is what puzzles me.



    ~~~~~~~~~~~~
    WEBFORM
    ~~~~~~~~~~~~
    <HTML>
    <body>
    <form id=frmMain method=post runat="server">
    <iframe id=ifrHTML name=ifrHTML ></iframe>
    <asp:Button id=cmdSend runat="server" Text="Send"></asp:Button>
    <input type=hidden name=hidValue>
    </form>
    <script>
    //Set the IFRame to Design Mode.
    ifrHTML.document.designMode="on"
    </script>
    </body>
    </HTML>



    ~~~~~~~~~~~~
    CODE BEHIND.
    ~~~~~~~~~~~~
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    cmdSend.Attributes.Add("onClick",
    "document.frmMain.hidValue.value = ifrHTML.document.body.innerHTML;")
    End Sub

    Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles cmdSend.Click
    Try
    Dim strValue As String
    strValue = Request.Form("hidValue")
    Catch ex As Exception
    Throw New Exception(ex.ToString())
    End Try
    End Sub

    L Anthony Johnson

    "Alex Papadimoulis" <alexp-at-halogenstudios.com> wrote in message
    news:...
    > This information is not sent back to the server. You would have to use
    > Javascript to place an IFrame's InnerHTML in an HTML Hidden Input tag and
    > read it that way.
    >
    > Alex Papadimoulis
    >
    > "L Anthony Johnson" <> wrote in message
    > news:uAiS$...
    > > Has anyone had any success doing this. I have tried, but the InnerHTML
    > > property always comes back as an empty string.
    > >
    > > L Anthony Johnson
    > >
    > >

    >
    >
     
    L Anthony Johnson, Nov 20, 2003
    #3
  4. L Anthony Johnson

    Rob Mayo Guest

    What I do is have my IFrame send a javascript method call to it's parent
    (the Page). The page holds the function to receive this call, and displays
    something accordingly. Whatever information it needs is passed via arguments
    to the function.


    "L Anthony Johnson" <> wrote in message
    news:...
    > I am doing the following. However whenever the text in the IFRame

    (ifrHTML)
    > has any type of formatting other than plaintext, the innerHTML is not
    > returned.
    >
    > If I do a CTRL+B (bold) or CTRL+U (Underline) or any other formatting.

    The
    > cmdSend_Click routine is not entered. That is what puzzles me.
    >
    >
    >
    > ~~~~~~~~~~~~
    > WEBFORM
    > ~~~~~~~~~~~~
    > <HTML>
    > <body>
    > <form id=frmMain method=post runat="server">
    > <iframe id=ifrHTML name=ifrHTML ></iframe>
    > <asp:Button id=cmdSend runat="server" Text="Send"></asp:Button>
    > <input type=hidden name=hidValue>
    > </form>
    > <script>
    > //Set the IFRame to Design Mode.
    > ifrHTML.document.designMode="on"
    > </script>
    > </body>
    > </HTML>
    >
    >
    >
    > ~~~~~~~~~~~~
    > CODE BEHIND.
    > ~~~~~~~~~~~~
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > cmdSend.Attributes.Add("onClick",
    > "document.frmMain.hidValue.value = ifrHTML.document.body.innerHTML;")
    > End Sub
    >
    > Private Sub cmdSend_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles cmdSend.Click
    > Try
    > Dim strValue As String
    > strValue = Request.Form("hidValue")
    > Catch ex As Exception
    > Throw New Exception(ex.ToString())
    > End Try
    > End Sub
    >
    > L Anthony Johnson
    >
    > "Alex Papadimoulis" <alexp-at-halogenstudios.com> wrote in message
    > news:...
    > > This information is not sent back to the server. You would have to use
    > > Javascript to place an IFrame's InnerHTML in an HTML Hidden Input tag

    and
    > > read it that way.
    > >
    > > Alex Papadimoulis
    > >
    > > "L Anthony Johnson" <> wrote in message
    > > news:uAiS$...
    > > > Has anyone had any success doing this. I have tried, but the

    InnerHTML
    > > > property always comes back as an empty string.
    > > >
    > > > L Anthony Johnson
    > > >
    > > >

    > >
    > >

    >
    >
     
    Rob Mayo, Nov 21, 2003
    #4
  5. Hi Anthony,

    Did you find a solution for this, I'm struggling with the same proble
    (creating a Content Management System), whenever I post the form an
    run a 'SaveData' procedure, the innerHTML is retrieved as the initia
    value, so all the editing done by the visitor is discarded....

    Cheers,

    Michael van den Berg
    Holland


    L Anthony Johnson Wrote:
    > Has anyone had any success doing this. I have tried, but the InnerHTML
    > property always comes back as an empty string.
    >
    > L Anthony Johnso


    --
    Michael van den BergPosted from http://www.pcreview.co.uk/ newsgroup acces
     
    Michael van den Berg, Jun 16, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mythran
    Replies:
    2
    Views:
    525
    Mythran
    Jan 22, 2005
  2. =?Utf-8?B?VGltOjouLg==?=

    Retieve last record in the DB???

    =?Utf-8?B?VGltOjouLg==?=, Jun 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    388
  3. Thor
    Replies:
    1
    Views:
    1,031
    Mikkel Heisterberg
    Jul 2, 2003
  4. Daedalous
    Replies:
    3
    Views:
    754
    Daedalous
    Jan 16, 2004
  5. sonic
    Replies:
    5
    Views:
    296
    Randy Webb
    Jul 11, 2006
Loading...

Share This Page