为什么用 ASP.NET 服务器控件代替 HTML 控件?
原文:https://www . geesforgeks . org/why-to-use-ASP-net-server-controls-in-place-html-controls/
基本上,HTML 控件是客户端控件,ASP.NET 控件是服务器端控件。
我们更喜欢 ASP.NET 控件作为我们的网络控件。和 HTML 控件一样,我们不能维护数据丢失的状态,因为它不提供状态管理。在编写代码时,我们不能从文件后面的代码中访问 HTML 控件。
因此,即使客户端的执行速度很快,我们也只喜欢 ASP 。NET 是因为以上两个原因。HTML 控件甚至不支持面向对象的范式,它只有一组有限的属性和方法,而 ASP.NET 完全支持面向对象的范式,可以从文件后面的代码直接访问它,并且它有一组丰富的属性和方法。
- ASP。 Net: ASP.NET is a server-side framework for web development, which provides services needed to develop enterprise-level web applications with minimal code. It is. NET framework, so it can access. NET framework, while writing ASP.NET code. It has better user authentication. It uses the compiled code to improve the performance of the application. ASP.NET page runs as code on the server. The page is configured so that when the user clicks the button, it will be submitted to the server. When the page is refreshed and submitted back to itself, it will run the ts server code again and present its new version to the user. Usually, the web form pages are compiled on the server as page objects and cached in the server memory. The ASP.NET page is the combination of all server-side controls and event handling codes in the page. The event handling codes are written in the code file behind the page, so the page is executed as a unit. When the user requests the page for the first time, the page is dynamically compiled and executed. Therefore, there is no need to precompile the page into an assembly. ASP.NET server control is controlled by an abstract strongly typed object model. They can be dragged to. Aspx page in toolbox. In addition, we can also include special controls, such as calendar controls and validation controls.
- namespace: We use the following namespace for web controls: system. The server is designed to make it easier to develop tools and applications. The process of creating web forms is now more efficient and simple. Commonly used web server controls include TextBox, Label, Button, CheckBox, RadioButton and GridView
- Verification control: Verification data is very important when obtaining data items from the user side. Besides the client, authentication should also be performed on the server side. Verification controls are usually placed near the controls they are verifying. Control validates data at the client before the postback process. Validation controls are placed on the web form, and then they set their Control Validation property to the control to validate. The validation summary control is used to display validation-related error messages of all controls at one time (that is, in one place). We even need to provide a control, such as a button that triggers a postback event. Although the verification occurs at the client, the verification process does not begin until the request is posted back.
- State management: State management is a mechanism that allows you to maintain state and page information in multiple requests for the same or different pages. The web pages developed by ASP.NET are based on HTTP, which is a stateless protocol. To overcome this limitation, ASP.NET supports several concepts to save data, which is called state management. ASP.NET provides different options for state management, which are client and server. On the client side, we use view state, hidden fields, Cookies and query strings. On the server side, we use applications, sessions and databases to store data.
版权属于:月萌API www.moonapi.com,转载请注明出处