asp.net.ph

Skip Navigation LinksHome > ASP.NET Web Forms > Web Forms Server Controls > Web Forms Server Controls overview

Web Forms Server Controls Overview

HTML Server Controls   Web Server Controls   Validation Controls   User Controls


HTML Server Controls

HTML server controls are HTML elements containing attributes that make them visible to — and programmable on — the Web server.

These controls enable page developers to dynamically access and manipulate HTML elements within a Web Forms page.

Any HTML element can be converted to an HTML control, simply by adding a runat="server" attribute and an id attribute to uniquely identify the HTML element.

<htmlelement id="uniqueID" runat="server">

The Web Forms framework, though, provides pre-defined HTML server controls for the HTML elements most commonly used dynamically on a page.

These include the HTML <form>, the HTML <input> elements ( text box, check box, radio button, submit button, and so on ), the HTML <select>, <table>, <image>, and so on.

These pre-defined HTML server controls share the basic properties of the standard HTML element, and in certain cases provide their own set of properties and events.

In addition, any other HTML element that does not explicitly map to one of the ASP.NET HTML server controls is handled by an HtmlGenericControl.

By assigning a unique id to the control, the control’s methods and properties can then be accessed programmatically, using the control’’s assigned identifier.

The below code snippet demonstrates how to dynamically set the InnerHtml property of an HTML <span runat="server"> control as the page loads.

<script language="C#" runat="server">
   void Page_Load ( Object sender, EventArgs e ) {
      myCtrl.InnerHtml = "Today is " + DateTime.Now.ToString ( "f" );
   }
</script>
... 
<span id="myCtrl" style="font-style:italic" runat="server" />
  C# VB JScript
HTML Server Control Syntax Example
Run Sample | View Source

For a quick overview of the available ASP.NET HTML controls, see HTML Server Controls.

More ...
Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note