I'm new to web programming and I've started with ASP.NET 2.0. I would like to know what the differences are when using an HTML control rather than an ASP control, and I'd like to know too how the attribute runat="server"
works.
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
The biggest deference in my opinion is that ASP.NET controls are executed on the server, with the resultant HTML sent to the client and that ASP .NET Server Controls can detect the target browser's capabilities and render themselves accordingly.
These are the differences between asp.net controls and html controls
HTML server controls :are HTML tags understood by the server.
HTML elements in ASP.NET files are, by default, treated as text. To make these elements programmable, add a
runat="server"
attribute to the HTML element. Thisattribute
indicates that the element should be treated as a server control. The id attribute is added to identify the server control. The id reference can be used to manipulate the server control at run time.Ex:
< input type="text" id="id1" runat="server" />
It will work. HtmlTextControl class< input type="button" id="id2" runat="sever" />
It will not work. For html button control there is no compatiable version of control class.corrected one is
htmlButton class
< input type="reset" id="id2" runat="sever" />
This one will not work.Web server controls are special ASP.NET tags understood by the server.
The syntax for creating a Web server control is:
These are also case insensitive. Here the important thing is to compulsory write runat="server". For HTML controls this is optional.
all HTML < input type="text" /> control's attributes are also available for these asp tagged server controls. Some special attributes are also there which we will discuss on Ajax for special attributes.