Retieve InnerHTML from an IFrame on the Server Side.

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
 
A

Alex Papadimoulis

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

L Anthony Johnson

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
 
R

Rob Mayo

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.
 
M

Michael van den Berg

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
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top