First, if you drag an Html control from a toolbar onto your design surface, as in your example, the created tag does not include runat = "server". This means that it is a native Html tag, not a .NET control. A native Html tag without runat = "server" does not have server-side functionality. Thus, you cannot set the value of the input tag "Text1" in the code.
Secondly, as soon as you add runat = "server" to your Html input tag, you convert it from your own Html tag to HtmlControl, which comes from System.Web.UI.Control. Now the question may turn into the differences between what comes from System.Web.UI.Control and System.Web.UI.WebControl. However, to specifically address your question, compare the standard input = text element with the TextBox control:
- The TextBox control can be accessed from code where the input control cannot (not easily), which also means that you can connect to server events for the TextBox control, while you cannot use the standard Html control.
- The TextBox control automatically saves its value using the ViewState.
- A TextBox control can be bypassed with a Theme and .skin file, while a native Html control cannot.
- A TextBox may appear as an input element = "text" or a text field, depending on its TextMode property.
- The TextBox control can participate in validation using validators.
- Last but not least, the TextBox control can use control adapters to render differently in different browsers, if necessary. See http://msdn.microsoft.com/en-us/magazine/cc163543.aspx .
Now, all that has been said, if you do not need any features of WebControl, then using your own Html control is significantly more compact. In your example, you simply dragged two empty controls onto your design surface. If that's all you need, then using a .NET control will be redundant. However, when you start adding AutoComplete events and server events, etc., Full content, Javascript and everything else that gets into the browser is much more.
Thomas
source share