473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Retieve InnerHTML from an IFrame on the Server Side.

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

L Anthony Johnson
Nov 18 '05 #1
4 5124
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" <pp*****@nospamm4m3bellsouth.net> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Has anyone had any success doing this. I have tried, but the InnerHTML
property always comes back as an empty string.

L Anthony Johnson

Nov 18 '05 #2
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:uN*************@tk2msftngp13.phx.gbl...
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" <pp*****@nospamm4m3bellsouth.net> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Has anyone had any success doing this. I have tried, but the InnerHTML
property always comes back as an empty string.

L Anthony Johnson


Nov 18 '05 #3
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" <pp*****@nospamm4m3bellsouth.net> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
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:uN*************@tk2msftngp13.phx.gbl...
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" <pp*****@nospamm4m3bellsouth.net> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Has anyone had any success doing this. I have tried, but the InnerHTML property always comes back as an empty string.

L Anthony Johnson



Nov 18 '05 #4

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

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Soren Vejrum | last post by:
I am working on a web-based html editor using MSIE's designmode and iframes. Everything works just fine, but MSIE changes all my relative "a href" and "img src" links (i.e. "/index.asp") to...
4
by: JimMenees | last post by:
(code is at end of post) ------------------------------------------- I'm using an i-frame to grab a server-side text file and display its content elsewhere in the html document. On change of the...
3
by: Angel | last post by:
How do I get the reference of the IFrame from the asp.net webpage that is being displayed within that IFrame? In other words I have an IFrame in my page. Within that IFrame Set the source to a...
22
by: Chris Moltisanti | last post by:
Hey, I have a DIV and I want to dynamically set its innerHTML. I know I can set it by doing the following myDiv.innerHTML = '<img src=\"myImage.gif\">' However, the html that I want to set in...
6
by: howa | last post by:
Since it is part fo the standard, why I always heard that we should avoid iframe? any comments? thanks.
5
by: Andrew Hedges | last post by:
Wherein I attempt to debunk some myths about the relative merits of the two methods for programmatically adding content to a web page: ...
6
by: honguin | last post by:
Hi, The current scenario is that I have an iframe inside an asp.net web page where I periodically check the url inside the iFrame. I know that all this information can be obtained in the...
22
by: Aaron Gray | last post by:
How do I set the innerHTML property of a contained IFRAME ? Many thanks in advance, Aaron
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.