如何从控制器中的视图获取 Html 内容?
在我的控制器中,我从位于 App_Code 中名为 QqPDF 的类调用静态函数来生成 pdf。我想要的是能够获取QqPDF中某些操作的html字符串并在我的pdf中使用它们。但我不知道如何从视图中获取字符串。
谢谢。
In my controller I call a static function from a class located in App_Code called QqPDF to generate a pdf. What I want is to be able to get the html string of some actions in QqPDF and use them in my pdf. But I don't know how to get the string from a View.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以查看以下内容文章 说明了如何从控制器中将某些部分或视图呈现为字符串。
You may take a look at the following article which illustrates how you could render some partials or views into a string from withing your controller.
也许您应该查看采用视图模型并显示它们的视图。如果其他地方需要此数据,请考虑将其存储在字符串资源或类似的资源中,然后将该项目传递到您的视图中。但也许您真正想要的是获取视图的渲染 HTML。也许这个答案将为您指明正确的方向
从控制器内部获取部分视图的 HTML
Perhaps you should view your views things that take a view model and display them. If this data is needed elsewhere consider storing it in a string resource or something like that and then pass that item into your view. BUT maybe what you really want is to get the rendered HTML of the view. Perhaps this answer will point you in the correct direction
Getting a Partial View's HTML from inside of the controller