为什么我会跑的Html在服务器控件? [英] Why would I run Html controls at server?

查看:167
本文介绍了为什么我会跑的Html在服务器控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我会永远运行的HTML服务器控件上?正如,我为什么要这么做呢?

 < p =服务器方式>这是一个段落< / P>


解决方案

您可能需要使用HTML控件相对于服务器控件的一个原因是给力呈现HTML得到一定的元素。

例如,一个 GridView控件默认情况下,将呈现为一个HTML表格,但你可能希望它呈现为的DIV为表较少布局。

HTML控件为在HTML输出的更大的灵活性;这是原因,人们喜欢ASP.NET MVC超过ASP.NET的WebForms之一,因为你控制更多的最终结果,而不是ASP.NET引擎决定为你的东西。

显然,随着动力来自责任,你会失去一些服务器控件的便利。

Why would I ever run Html controls on the server? As in, why would I want to do this?

<p runat = "server">This is a paragraph.</p>

解决方案

One reason you might want to use the HTML controls versus the server controls is to force the rendered HTML to be of a certain element.

For example, a GridView by default will render as an HTML table, but you may want it to render as DIVs for a table-less layout.

HTML controls give your more flexibility in the HTML output; which is one of the reasons people like ASP.NET MVC over ASP.NET WebForms, because you are controlling more of the end result instead of the ASP.NET engine deciding certain things for you.

Obviously, with power comes responsibility, you will lose some of the conveniences of server controls.

这篇关于为什么我会跑的Html在服务器控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆