Page 69 - DCAP312_WEB_TECHNOLOGIES_II
P. 69

Unit 4: Advanced Server Controls



            4.1.2 Difference between Web Server Control and Html Server Control                   Notes
            Web Server Controls are collection of controls imitative straight from the arrangement.Web.
            UI.WebControls  base  class.  They  are  reusable  components  that  can  execute  function  as  the
            ordinary HTML controls; the real benefit of web controls is that they are programmable i.e.
            they can treated and accessed the same way as any other .NET classes. They therefore respond
            to events, have methods /functions and can basically do all that other .NET classes can do.
            The main issue 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 abreacting 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.HtmlControlsnamespace.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”>

            Although  these  two  categories  may  have  overlapping  functionality  and  may  be  even  used
            synonymously they have important differences. Such as
               1.  HTML s controls offer one to one mapping with html tags no abstraction; Web s controls
                 do not necessarily map to any html tag e.g. 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 htmls controls.
            4.1.3 HTML Server Controls Advantage

               1.  ASP .NET Server Controls can detect the target browser’s capabilities and render themselves
                 accordingly. No issues for compatibility issues of Browsers.

               2.  Processing would be done at the server side.
               3.  ASP .NET Server Controls have an object model different from the traditional HTML and
                 even provide a set of properties and methods that can change the outlook and behaviour
                 of the controls.
               4.  ASP .NET Server Controls has higher level of abstraction. An output of an ASP .NET
                 server control can be the result of many HTML tags that combine together to produce
                 that control and its events. Example Grandview or Form control.
               5.  The HTML Server Controls follow the HTML-centric object model. Model similar to HTML.
               6.  Here the controls can be made to interact with Client side scripting. Processing would be
                 done at client as well as server depending on our code.
            4.1.4 Html Server Controls Disadvantage

               1.  You would need to code for the browser compatibility.



                                             LOVELY PROFESSIONAL UNIVERSITY                                    63
   64   65   66   67   68   69   70   71   72   73   74