Retieve InnerHTML from an IFrame on the Server Side.

  • Thread starter Thread starter L Anthony Johnson
  • Start date Start date
L

L Anthony Johnson

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

L Anthony Johnson
 
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
 
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
 
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.
 
Hi Anthony,

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

Cheers,

Michael van den Berg
Holland


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

L Anthony Johnson
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top