I'm working on the MVC app where I've to generate the report in the form of HTML page. If the user click the print icon, I've to show the HTML page to user. If t开发者_运维知识库he user click on email icon, I've to send email with same HTML page attachment. I'm trying to find a way where I can use the same code to generate the HTML in both cases of email and print. Please provide your suggestions.
What you really want and did not know how to formulate is Render view to string. Then you can do whatever you want with the contents of that string.
Start here Render a view as a string
but this subject continues in many other questions too (or you can Google it) and you will discover much more information.
Your Controller has to decide what to do.
- User clicked print. Controller action: collect data, prepare the View, display as HTML page
- User clicked email. Controller action: collect data, prepare the View, call on an email-function and use the output of the HTML page as an attachment.
精彩评论