Search This Blog

Mar 4, 2010

Difference between html server controls and web server controls







Difference between html server controls and web server controls


html server controls

these are the HTML elements exposed to the server so as u can program them by writing this attribute in the source window by writing , runat = "server" which makes the html elements work as a html server controls.

additionally,if u write
tags which is used for paragraph, this tag will act as a static text that is passed through to the browser , if u write this tag in a server - side code.


u know there is difference between html elements and html server controls>>>>

u can make the html elements to work as a html server controls by simple conversion
you expose the html controls as html server controls by writing runat="server" attribute in the source code window .

what is the need to add this attribute?

this attribute tells the ASP.NET page framework that it should create an instance of the control during parsing for use during server - side processing.


FEATURES OF HTML SERVER CONTROLS:
  • Data binding for one or more properties of the control.
  • ability to handle events in client script.
  • Automatic maintenance of the control's state. if the form makes a roundtrip to the server, the values that the users entered into HTML server controls are automatically maintained when the page is sent back to the browser.
  • An object model that you can program against on the server.Each server control exposes properties that allow you to manipulate the HTML attributes programmatically in server code.
  • A set of events for which you can write event handlers in much the same way that you would in a client-based form . However, the event is handled in server - side code.



Web server controls


these are the controls designed differently from HTML controls with complex behavior by simply dragging from the tool box.

these controls include traditional form controls , such as buttons and text boxes, in addition to complex controls such as tables, calenders , and tree views.

FEATURES OF WEB SERVER CONTROLS:

  • Rich model object that provides type - safe programming capabilities.
  • Automatic browser detection .create appropriate output for both basic and rich browser.
  • Ability to define consistence appearances for the controls by using templates.
  • Post Back event and auto post back event causes immediate posting to the server or is instead cached and raised when the form is submitted.
  • ability to pass events from a nested control, such as button in a table, to the container control.

>> see this pattern to understand about the object model



when the web forms page runs, ASP.NET renders the web server control on the page by using appropriate HTML , which often depends not only on the browser type, but also on the settings that you have made for the control. for example , a text box control might render as an tag or a



MAIN DIFFERENCE BETWEEN HTML SERVER CONTROLS AND WEB SERVER CONTROLS WHICH MAKES THEM UNIQUE FROM EACH OTHER

  In html server controls,the object model for HTML server controls maps closely to that of the corresponding elements.for example,HTML server controls as properties .
                    
                                   whereas web server controls do not map one to one to HTML server controls.instead they are abstract controls,in which the HTML rendered can be quite different from the model that you program against. for example, RADIOBUTTONLIST web server control might be rendered in a table or as inline text with other HTML .
              

the object model for html server controls maps closely to that of corresponding elements. for example, HTML attributes are exposed in HTML server controls as properties. whereas, web server controls do not map one -to -one to HTML server controls.Instead, they are abstract controls,in which the HTML rendered can be quite different from the model that you program against .For example, a RADIOBUTTONLIST web server control might be rendered in a table or as inline text with other HTML.