1

I have a web app that displays a table the user can edit. In the process of editing, various inner HTML of the original table gets replaced with edits made by the user. Once the user is finished I would like to save the resulting table in a .html file so that I can include it in a PowerPoint slide without having to recreate it. Basically I want to capture the .aspx file as is after editing and write this to a file.

Any advice is appreciated.

Regards.

3
  • Are you looking to save the file on the client or the server? Commented Aug 9, 2012 at 19:53
  • Also are you doing the editing client side via javascript, or through postbacks to the server? Commented Aug 9, 2012 at 19:53
  • Way too vague... I have no idea how you're implementing your solution, and that's a huge part of any answer. On top of all that, you didn't actually ask a question. Commented Aug 9, 2012 at 19:59

3 Answers 3

4

Basically I want to capture the .aspx file as is

Because you state "capture the ASPX", I'm assuming the data edits are persisted somewhere (memory/database). This means it is straightforward to override the Render() method of the control/page and redirect (or copy) the output stream to a file.

Example

protected override void Render( HtmlTextWriter writer ) { using( HtmlTextWriter htmlwriter = new HtmlTextWriter( new StringWriter() ) ) { base.Render( htmlwriter ); string renderedContent = htmlwriter.InnerWriter.ToString(); // do something here with the string, like save to disk File.WriteAllText( @"c:\temp\foo.html", renderedContent ); // you could also Response.BinaryWrite() the data to the client // so that it could be saved on the user's machine. // and/or write it out to the output stream as well writer.Write( renderedContent ); } } 

Sequence

  • User enters data
  • You store the results somewhere
  • You re-render the control with the most recent content
  • Capture the output of the control and write it out to a file
Sign up to request clarification or add additional context in comments.

Comments

2

If you are doing it client side you can do something like this using jquery

http://jsfiddle.net/BAVzC/3/

You can then copy paste to a text file.

Comments

1

Just a few pointers.

You can get the whole inner html of a section of your page using jquery functions like html

You can use ajax to send this to your server.

You could write an http handler to receive this at the server. Since you only plan to save this to a fixed format html file, nothing else is required. I would not use a page to so as to avoid the extra overhead of creating all the controls, and a page will not receive html input unless you set ValidateRequest to "false".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.