Home ASP.NET Hosting Dedicated Servers Contact Us
Announcements
Virtual Tiers
.NET Applications
XML Web Services
SQL Server Database
Web Traffic Statistics
Much More...
ASP.NET Web Site Hosting
Dedicated Servers
Windows 2003 Server
2.4 GHz Pentium 4
1024 MB RAM
80 GB Hard Drive
1000 GB/month
Fully Managed
Free Setup!
$268.00/month
Windows Dedicated Servers
Specialized Plans
10 or more Domains
Windows Services
Custom Plans
Windows Services
Learning & Support
About Us



Introduction to ASP.NET Server Controls



Learn More about Server Intellect



In addition to (or instead of) using <% %> code blocks to program dynamic content, ASP.NET page developers can use ASP.NET server controls to program Web pages. Server controls are declared within an .aspx file using custom tags or intrinsic HTML tags that contain a runat="server" attribute value. Intrinsic HTML tags are handled by one of the controls in the System.Web.UI.HtmlControls namespace. Any tag that doesn't explicitly map to one of the controls is assigned the type of System.Web.UI.HtmlControls.HtmlGenericControl.

The following sample uses four server controls: <form runat=server>, <asp:textbox runat=server>, <asp:dropdownlist runat=server>, and <asp:button runat=server>. At run time these server controls automatically generate HTML content.

<html>
<head>
</head>

<body>

<center>

<form action="form.aspx" method="post" runat=server>

<h3> Name: <asp:textbox id="Name" runat="server"/>

Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem >psychology</asp:listitem>
<asp:listitem >business</asp:listitem>
<asp:listitem >popular_comp</asp:listitem>
</asp:dropdownlist>
</h3>

<asp:button text="Lookup" runat="server"/>

</form>

</center>

</body>
</html>


Important: Note that these server controls automatically maintain any client-entered values between round trips to the server. This control state is not stored on the server (it is instead stored within an <input type="hidden"> form field that is round-tripped between requests). Note also that no client-side script is required.

In addition to supporting standard HTML input controls, ASP.NET enables developers to utilize richer custom controls on their pages. For example, the following sample demonstrates how the <asp:adrotator> control can be used to dynamically display rotating ads on a page.

html>
<head>
</head>

<body>

<center>

<form action="form.aspx" method="post" runat="server">

<asp:adrotator AdvertisementFile="ads.xml" BorderColor="black" BorderWidth=1 runat="server"/>

<h3> Name: <asp:textbox id="Name" runat="server"/>

Category: <asp:dropdownlist id="Category" runat=server>
<asp:listitem >psychology</asp:listitem>
<asp:listitem >business</asp:listitem>
<asp:listitem >popular_comp</asp:listitem>
</asp:dropdownlist>
</h3>

<asp:button text="Lookup" runat="server"/>

</form>

</center>

</body>
</html>


ads.xml

<Advertisements>

<Ad>
<ImageUrl>banner1.gif</ImageUrl>
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>

<Ad>
<ImageUrl>banner2.gif</ImageUrl>
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>

<Ad>
<ImageUrl>banner3.gif</ImageUrl>
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<AlternateText>Alt Text</AlternateText>
<Keyword>Computers</Keyword>
<Impressions>80</Impressions>
</Ad>

</Advertisements>