如何更改response.write()的位置; [英] How to change the position of response.write();
问题描述
所以这是观点:
@model CMSFC.Models.Page
@ {
Layout =〜/ Views / Shared / _Layout.cshtml;
}
@ {
Response.Write (Model.Template);
}
它从数据库中呈现一个html表(保存在Template列中),使用页眉页脚体等等。但是这会在应用程序的左上角呈现一个非常小的表,我想在整个视图屏幕上呈现该html表。
我的尝试:
----------------- ---------------------
如果,请注意Mode.Template
是你要在浏览器上写的原始HTML内容,然后我会采用不同的方法,
@ Html .Raw(Model.Template)
这将从数据库呈现HTML内容,并且仍然遵循生成布局和填充视图信息的MVC语义和过程。在任何情况下,都不是一个好的方法来进行Response.Write()。 Response.Write用作<%variable%>的替代值。经典ASP的方法,有时在ASP.NET网页中,但在ASP.NET MVC中,您需要遵循MVC模式,以更好地利用此框架中提供的服务和功能,这些服务和功能由@Html
帮助者。
如何使用@html.raw | ASP.NET论坛 [ ^ ]
ASP.NET中的Response.Write是不是一个坏主意? - 堆栈溢出 [ ^ ]
编辑
您也可以将样式应用于表格本身。但是遵循语义仍然更好。 : - )引用:但这会在应用程序的左上角呈现一个非常小的表,我想在整个视图屏幕上呈现该html表。
So this is the view :
@model CMSFC.Models.Page @{ Layout = "~/Views/Shared/_Layout.cshtml"; } @{ Response.Write(Model.Template); }
It renders a html table (saved in Template column) from database , with header footer body and so on .. But this renders a very small table on the top left corner of the application , i want to render that html table on the entire screen of view .
What I have tried:
--------------------------------------
On a side note if thatMode.Template
is the raw HTML content which you want to write on the browser, then I would follow a different approach,
@Html.Raw(Model.Template)
This would render the HTML content from database, and still follow the MVC semantics and processes of generating Layout and filling the View information. It is not a good approach to go a Response.Write(), in any case. Response.Write was used as alternate to the <% variable %> approach of Classic ASP and sometimes in ASP.NET Web Pages, but in ASP.NET MVC you need to follow the MVC pattern to better make use of the services and features provided in this framework, which are provided by the@Html
helpers.
how to use @html.raw | The ASP.NET Forums[^]
Is Response.Write in ASP.NET views a bad idea? - Stack Overflow[^]
Edit
Quote:But this renders a very small table on the top left corner of the application , i want to render that html table on the entire screen of view .
You can apply the styling to the table itself as well. But it is still better to follow the semantics. :-)
这篇关于如何更改response.write()的位置;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!