Click here to check my latest exciting videos on youtube
Search Mallstuffs

Flag Counter
Spirituality, Knowledge and Entertainment


Locations of visitors to this page


Latest Articles


Move to top
Working with server controls and HMTL controls
Posted By Sarin on Apr 17, 2012     RSS Feeds     Latest Hinduism news
2778 Views

HTML controls do process on client side whereas Server controls run on server side
For Html controls, the server is hit only on page submit. But for server controls on every user response the server is hit.  
Server controls run server side and html controls run browser side and as well as client side.  
Server Control can internally maintain the state by using (EnableViewState property) whereas HTML controls are not having such property to maintain the state.
HTML controls have no direct properties available to set the colors or font used by the control whereas many serevr controls has the direct property of setting font and colors.
  
IIS convert all server controls to HTML control.
Microsoft has abstracted server controls so that the user can perform complex operation with ease using these server controls which otherwise is time-consuming to achieve using html controls.
All server controls are converted to html controls at runtime by IIS. To check it in action, let us see the following example. Suppose you write the code as follows:
<body>
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit <a href="https://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
    </p>
    <asp:HyperLink runat="server" ID="lnkKrishna" text="Hare krishna"/><br />
     <asp:Label runat="server" ID="lblKrishna" text="Hare krishna"/>
  </body>
Above code have two html controls and two server controls.
Now let us run this code using visual studio and check the source code generated
  

  
As you can see, html controls remains as it is whereas the server controls is converted to html controls by IIS. i.e  asp:HyperLink changed to anchor tag   and asp:Label changed to span tag
Converting HTML control to server control
The html controls can be made to run on server side by using runat="server".  

When we can covert html controls to server controls by using runat = server then why should we use the server control?
We use server controls to provide more advanced properties and functionality as compared to built in HTML controls. For example, we can use server chart controls which is not available in server controls.

Performing validations
We can validate html controls using JavaScript or Regular expressions.
On the server side you can use validation controls such as compare validator, range validator,custom validator etc to perform validations according to the requirement. Based on our requirement, we can use one or more of this validator controls.
Remember, Server Side Validation must always be performed, then optionally Client Side validation to enhance the user experience.  
  
Advantages and disadvantages of .Net server controls:  
Advantages:
There are many server controls that can be used in the same manner as any HTMl control Ex: Calender controls. (No need of Activex Control or any other third party dll).
ASP .NET Server Controls renders the code after detecting the user browser's capabilities and hence, the rendered code changes from browser to browser. So, there is no compatibility issues of Browsers and you don’t have to take extra effort of writing code considering browser capabilities since this task is done by the IIS.
ASP .NET Server Controls has higher level of abstraction. An output of an ASP .NET server control can many HTML tags combined together to produce that control and its events.
Processing is done at the server side. Validations controls are available to make the validation tasks easier. So no need to choose between scripting language which would be incompatible with few browsers.
ASP .NET Server Controls have an object model different from the traditional HTML and even provide a set of properties and methods, not available in HTML controls, that changes the outlook and behavior of the controls.
Server controls expose and raise server events on user actions which give user the flexibility to meet lot of their requirement like setting some property at runtime whereas the same cannot be achieved by html controls
Disadvantages:
You don’t know exactly how the code will be rendered. So you have no much of direct control on these controls unless you go though the generated source code.
Migration of ASP to any ASP.NET application is difficult. Its equivalent to rewriting your new application
  
Advantages and disadvantages of HTML Server Controls
Advantages:
The HTML Server Controls follow the HTML-centric object model.  
Here the controls can be made to interact with Client side scripting. Processing would be done at client as well as server depending on your code.
Migration of the ASP project thought not very easy can be done by giving each intrinsic HTML control a runat = server to make it HTML Server side control.
The HTML Server Controls have no mechanism of identifying the capabilities of the client browser accessing the current page.
A HTML Server Control has similar abstraction with its corresponding HTML tag and offers no abstraction.
  Disadvantages:
You would need to code for the browser compatibility.
  
  
  
Note: Images used on this website are either a production of Bhaktivedanta Book Trust(https://www.krishna.com), Iskcon Foundation or were found in google search under "Free to use and share". If any of the images presented here violates copyright issues or infringes anyone copyright or are not under "Fair use", then please bring it to our notice. Read Disclaimer for more.

Share this to your friends. One of your friend is waiting for your share.
Related Articles
Cloning HTML Elements using jquery
Select Groups of similar elements using position selector
Working with Dockpanel in silverlight
Select Parent, Child, sibling,descendants HTML element using jquery
Playing with HTML using Jquery
Ge the total number of HTML elements in a page
Show Update Progress Animation-Ajax
Jquery features, Advantages and disadvantages
Appending Html elements or contents dynamically
Ways of implementing AJAX

Post Comment