Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part III: Namespace Reference > The System.Web.UI.HtmlControls Namespace

Chapter 39. The System.Web.UI.HtmlControls Namespace

The System.Web.UI.HtmlControls namespace includes classes for HTML server controls. HTML server controls are ASP.NET controls that raise events on the server and provide a simple object model that allows you to set some basic properties. Unlike web controls, which are found in the System.Web.UI.WebControls namespace, each HTML server control corresponds directly to an HTML element like <textarea> or <input>. Web controls are generally preferred in ASP.NET development because they are abstracted away from the low-level HTML details and they provide a richer object model with many more events, sophisticated data binding, automatic state management, and validation controls. HTML server controls are most often used when upgrading existing ASP pages. A standard HTML element can be converted into an HTML server control by adding the attribute runat="server" in the tag. This makes it extremely simple to convert a static HTML page into a dynamic page that allows controls to be manipulated as objects during postbacks.

All controls in this namespace derive from HtmlControl. This class provides basic functionality, including a name/value collection of attributes and CSS style properties. In addition, controls that require both an opening and closing tag inherit from HtmlContainerControl. This class adds a HtmlContainerControl.InnerText and HtmlContainerControl.InnerHtml property which allow you to access the text contained inside the tag. HTML elements that don't have corresponding classes can be represented by the HtmlGenericControl class. Note that only button and hyperlink controls trigger server postbacks. Many controls provide a ServerChanged event, which won't fire after a control is modified until a postback occurs.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint