ASP control vs HTML control

I am new to web programming and I started with ASP.NET 2.0. I would like to know the differences when using an HTML control rather than an ASP control, and I would also like to know how the runat="server" attribute works.

+6
source share
2 answers

These are the differences between asp.net controls and html controls

  • HTML server management:

HTML server controls: These are HTML tags that the server understands.

HTML elements in ASP.NET files are treated as text by default. To make these elements programmable, add the runat="server" attribute to the HTML element. This attribute indicates that the item should be considered as a server control. The id attribute is added to identify the server control. The identifier reference can be used to control the server at runtime.

Note. All HTML server controls must be within the <form> using runat = "server". The runat = "server" attribute indicates that the form should be processed on the server. This also indicates that private controls can be accessed by server-side scripts.

Example: < input type="text" id="id1" runat="server" /> This will work. HtmlTextControl Class

< input type="button" id="id2" runat="sever" /> This will not work. There is no compatible control class version for html buttons control.

fixed:

 < input type="submit" id="id2" runat="server" /> 

htmlButton class

< input type="reset" id="id2" runat="sever" /> This will not work.

  • ASP.NET - Web Server Management

Web server elements are special ASP.NET tags that the server understands.

Like HTML server controls, web server controls are also created on the server, and this requires the runat = "server" attribute. However, Web server controls are not necessarily mapped to any existing HTML element code, and they can represent more complex elements.

The syntax for creating a web server control is:

 < asp:textbox id="Textbox1" runat="server" /> 

They are also case insensitive. The enforced runat = "server" entry is important here. For HTML controls, this is optional.

all HTML <input type = "text" / "> control attributes are also available for these assembled server controls. There are also some special attributes that we discuss in Ajax for special attributes.

+6
source

The biggest respect, in my opinion, is that ASP.NET controls are executed on the server, and the received HTML code is sent to the client, and that ASP.NET-server controls can determine the browser’s targeted features and display them accordingly.

0
source

Source: https://habr.com/ru/post/899864/


All Articles