Kamran Shakil
In ASP.NET 1.0 you would find a number of server controls, identified by <asp: prefix > and can be categorized as
- HTML Server Controls
- Web Form Controls
- List Controls
- Rich Controls
- Validation Controls
- Mobile Controls
With Server Controls we get following benefits :
- XProvides consistent naming standard
- XProvides consistent properties
- XProvides consistent event-model
- XEmit pure HTML or HTML plus client-side Javascript.
- XEmit device-specific code.
All server controls have properties, methods and events in common. They provide ease for developers to build UI(User Interface) at convenience. Following code provides a BUTTON server control on the server :
<asp:Button text="submit" runat="server"/>
When this button be pressed, it would generate following HTML code to the client :
<input type="submit" name='ctrl1" value="Submit"/>
The above two code lines lines resemble eachother a lot, but the first one is executed on the server and the client never sees it ! With server controls you can do multitude of events like clicking a button, clicking a link, filling a textbox, filling a label, selecting items from list, combobox etc.
The important point to note over here is that all of these events are handled on the server, so everytime when an event occurs, the client posts the data to the server .
For practical and excitement, write the following snippet and save the file with the extension of .aspx in Inetpub\wwwroot folder, and fire your browser and run with http://localhost/
<%@ language=C# %>
<form action="a1.aspx" >
<asp:textbox id="aa" runat="server"/>
<asp:button text="Click a.aspx" runat="server" />
</form>
And see the source of the code, you would find it quite strange ? See for yourself.