简体   繁体   English

与asp.net控件和html控件混淆

[英]Confused with asp.net controls and html controls

We are plannning to use Ajax in our ASP.net project. 我们计划在ASP.net项目中使用Ajax。 However, we still want the member panel of our web site to work in all browsers. 但是,我们仍然希望我们网站的成员面板能够在所有浏览器中运行。 We have decided not to use Ajax in some forms where browser independence is must. 我们已经决定在某些必须独立于浏览器的形式中不使用Ajax。

I am now confused with whether we should use ASP.NET controls or HTML controls or both? 我现在对应该使用ASP.NET控件还是HTML控件还是同时使用两者感到困惑?

I have two questions: 我有两个问题:

  • Are there any problems that I might face using either of approach? 使用任何一种方法都可能遇到任何问题?
  • Also which one is better considering efficiency and performance? 考虑到效率和性能,哪个更好?

The Asp.Net Controls including the ajax controls are independent of browsers, asp.net will detect your browser and try to render the best html/javascript for that browser. 包括ajax控件在内的Asp.Net控件独立于浏览器,asp.net将检测到您的浏览器,并尝试为该浏览器呈现最佳的html / javascript。 So you are good with server controls. 因此,您对服务器控件很满意。

If you are going to implement the project in asp.net then for all the controls that need to be accessed via code at server side needs to be asp.net controls. 如果要在asp.net中实现该项目,那么对于需要通过服务器端代码进行访问的所有控件,都需要使用asp.net控件。 Those controls that are static and only displaying some value can be html controls. 那些静态的并且仅显示一些值的控件可以是html控件。

The main point is that the asp.net controls are rendered to html controls... so the client who views the web-page actually gets the html controls. 要点是asp.net控件呈现为html控件...因此,查看该网页的客户端实际上是html控件。

For AJAX refer this 对于AJAX,请参考

ASP controls and HTML controls as complementary. ASP控件和HTML控件作为补充。

ASP controls bring facilities for programming like the viewstate (the control keeps its content after a post back), the binding with datatable, and a lot of presentation properties. ASP控件为编程提供了便利,例如视图状态(控件在回发后保留其内容),与数据表的绑定以及许多表示属性。 It is really an advantage in terms of time and maintainability to use these controls. 就时间和可维护性而言,使用这些控件确实是一个优势。 They also manage some security feature like html code injection. 他们还管理一些安全功能,例如html代码注入。 ASP controls could be controled and managed from the code behind page. 可以通过页面后面的代码来控制和管理ASP控件。

HTML controls are out of the native ASP.NET page process. HTML控件不在本机ASP.NET页面过程中。 It is sometime a good thing to have particular control that you don't want ASP.NET take in charge and modify, but it is not the core of an ASP.NET web application. 有时,最好不要让ASP.NET负责和修改特定的控件,但这并不是ASP.NET Web应用程序的核心。

If you can use HTML - it is always better - as it is much faster. 如果可以使用HTML,它总是更好-因为它快得多。 The use of ASP controls should work on all browsers as far as I know, but it less efficient. 据我所知,ASP控件的使用应可在所有浏览器上使用,但效率较低。 Better create a small example and test it on some browsers before you decide. 在决定之前,最好创建一个小的示例并在某些浏览器上对其进行测试。

(I've used ajax on both explorer and Firefox and it works) (我在资源管理器和Firefox上都使用过ajax,并且可以使用)

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

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