Saving the page as a draft

hi, I'm implementing an e-mail client style web page.

User writes a text into a iframe
[contentEditable = true]

I've a safe draft button.
When the user click's it. I want to save the content of the iframe to a text file on the server. So that, I can load it later again.

So, the compact question is: How to get the content of a iframe from the  codebehind.

Note: iframe is already labeled as runat="server"
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason ScolaroCommented:
Hi tolgaong,

Well, an <iframe> doesn't allow typing of text, so I'm assuming you mean there is a TextBox or <textarea> inside of the <iframe> that you want to retrieve its contents.  So what you'll need to do is create a JavaScript function that access the iframe's TextBox and then stores the contents into a hidden control on the parent page.  This call can occur on the onclick event of the button that's meant to save the Draft.  In ASP.NET 2.0, it'd be the OnClientClick event.  Then in your code-behind you'll simply access the hidden control's Value property and then you're all set.

-- Jason
Jason ScolaroCommented:

This JavaScript works in IE:
document.getElementById("MyHiddenControlID").value = window.frames["MyiFrameID"].document.getElementById("TextBox1").value

Then on your parent page you would have something like:
<input type="hidden" id="MyHiddenControlID" runat="server" />

Good luck!
-- Jason
tolgaongAuthor Commented:
Let me change the question a bit.
I really have an iframe only.
Then I load a local webpage into this iframe (set src=...)
then, I set the contentEditable property to true. So the user can manuplate the html file. (writes text mostly)
And when he is ready. I want to save the final html
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

in your codebehind try getting to the contents with iframename.innerHtml ;)
This tutorial explains it better

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason ScolaroCommented:

I can honestly say I've never heard of that contentEditable attribute.  I'm assuming this is an IE only feature?

andycwk, I actually tested that myself before my post and it doesn't work.  I assume since it considers itself another Frame on the page.  Although with this contentEditable attribute, who knows what that produces.

My guess is you'll have to use the same sort of code, except more like so:
document.getElementById("MyHiddenControlID").value = window.frames["MyiFrameID"].document.body.innerHTML;

-- Jason
Jason ScolaroCommented:
Sorry, posted a bit late -- my reference to andycwk was regarding his 1st post, not the 2nd one.
np.. I had a feeling the first suggestion wouldn't work... Hence the second :(

tolgaongAuthor Commented:
I examined the link andycwk send.
This is what I was looking for. I couldn't made it to work yet but I'll work on it. Thanks andycwk. You got the points. ;)
sweet.. thx for the points and good luck with the project :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.