简体   繁体   English

在ASP.NET中使用HTML控件比使用ASP.NET控件有效吗?

[英]Is using HTML controls in asp.net effective than using asp.net control.?

I have been working and developing website in asp.net. 我一直在asp.net中开发网站。 Now, I want to try HTML5 and html controls in my asp.net website. 现在,我想在我的asp.net网站上尝试HTML5和html控件。 It came to when I was reading that using HTML(5) controls and flex make the website lighter. 当我读到使用HTML(5)控件和flex使网站更轻巧时,我想到了。 I am following W3 schools. 我正在关注W3学校。 Can I get some more knowledge on using the html controls in asp.net websites.? 我可以在asp.net网站上获得更多有关使用html控件的知识吗? Can I get some useful links. 我可以得到一些有用的链接吗?

Thanks in advance. 提前致谢。

If you definitely do not want to add ViewState overhead, then use HTML controls rather than ASP.NET server controls. 如果您绝对不想增加ViewState开销,请使用HTML控件而不是ASP.NET服务器控件。 But beware, ViewState is the glue for a lot of ASP.NET server controls being able to "remember" their values between post backs to the server. 但是请注意, ViewState是许多ASP.NET服务器控件的粘合剂,它们能够“记住”回发到服务器之间的值。

If you want more control over the output HTML, then use HTML controls, because the HTML control will map directly to the corresponding HTML element, rather than be rendered as potentially another HTML element or group of HTML elements, for example: 如果要对输出HTML进行更多控制,请使用HTML控件,因为HTML控件将直接映射到相应的HTML元素,而不是呈现为可能的另一个HTML元素或一组HTML元素,例如:

  • ASP.NET Literal server control will not render as an element, but rather just text. ASP.NET Literal服务器控件将不会呈现为元素,而只会呈现为文本。
  • ASP.NET GridView server control will render as an HTML table container, by default, and then literal text for BoundField s and various other elements for TemplateField s. 默认情况下,ASP.NET GridView服务器控件将呈现为HTML table容器,然后呈现为BoundField的文本文本和TemplateField的各种其他元素。
  • ASP.NET CheckBoxList server control will render as an HTML table container and then an input element for each individual check box. ASP.NET CheckBoxList服务器控件将呈现为HTML table容器,然后呈现为每个复选框的input元素。
  • ASP.NET TextBox will render as an HTML input element if it is single line of text or as an HTML textarea if it is multiple lines of text. 如果ASP.NET TextBox是单行TextBox则将呈现为HTML input元素;如果是多行TextBox则将呈现为HTML textarea

Finally, in some ASP.NET Frameworks, like SharePoint, certain server controls get rendered differently depending upon how many items are in the result. 最后,在某些ASP.NET Framework(如SharePoint)中,某些服务器控件的呈现方式会有所不同,具体取决于结果中有多少项。 For example if you have a lookup list with 19 or fewer items, then SharePoint will render the items as simple drop list (HTML element option with a select element for each value), but if the amount of items is 20 or more, then SharePoint decides to render a more complex combo box with jQuery support for auto-suggest. 例如,如果您有一个包含19个或更少项目的查找列表,则SharePoint将这些项目呈现为简单的下拉列表(HTML元素option ,每个值都有一个select元素),但是如果项目的数量为20个或更多,则SharePoint决定渲染具有jQuery支持自动建议功能的更复杂的组合框。 This is a case where you are at the mercy of the ASP.NET rendering engine for what ultimate HTML is produced. 在这种情况下,您只能依靠ASP.NET呈现引擎来生成最终的HTML。

check out the link 查看链接
Difference Between ASP.NET Server Controls,HTML Server Controls and HTML Intrinsic Controls I think this will help you to understand the difference between asp.net controls and html controls ASP.NET服务器控件,HTML服务器控件和HTML内部控件之间的区别我认为这将帮助您了解asp.net控件和html控件之间的区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM