zimcoder Level: VB Lord

 Registered: 27-10-2003 Posts: 225
|
Re: difference between web server control and html server control in asp.net?
Web Server Controls are group of controls derived directly from the System.Web.UI.WebControls base class. They are reusable components that can perform function as the ordinary HTML controls, the real advantage of web controls is that they are programmable.. ie they can treated and accessed the same way as any other .NET classes. They therefore repond to events, have methods /functions and can basically do all that other .NET classes can do. The main isuue to note is that the processing of these controls is done on the server. Consider:
| <asp:Button id="MyButton" runat="server" Text="This is Zimcoder's button"/> |
the key attribute is the "runat" which is set to the value "server" , this is their default value
Web Server Controls are rendered as standard html to client browsers thus abracting the functionality. They also make it easy to deal with complex controls such as the Calendar control which would be hell to implement in html!
HTML server controls map directly to html tags. They are defined in System.Web.UI.HtmlControls namespace. The base class is System.Web.UI.HtmlControls.HtmlControl. Html tags are converted to Html server controls by including the runat attribute in their declaration and setting it to server. Consider
<input type="button" id="mybutton" name="mybutton" value="click me" runat="server">
te only difference between this tag declaration and that of a normal html button tag is the runat attribute.
Although these two categories may have overlapping functionality and may be even used synonymously they have important differences. such as
1)HTMl s conctrols offer one to one mapping with html tags .. no abstraction, Web s controls do not necessarily map to any html tag .. eg calendar control.
2)Html attributes are not stronly typed to html s controls.. web s controls have strongly typed attributes making for easier access to methods and properties of the base class.
3)Html s controls do not distinguish between browsers though are not always rendered in a predictable way across browsers.. Web s controls were designed with this in mind.
4)web server controls can be extended as the developer sees fit to come up with custom controls.. not so easily or intuitively doable with html s controls..
hope i have clarified one or two things
____________________________
BrainBench ADO.NET and ASP.NET Certified Developer
 
|