0% found this document useful (0 votes)
2 views5 pages

ASP.net - HTML Server

The document explains HTML server controls in ASP.NET, which are standard HTML controls enhanced for server-side processing by adding the 'runat="server"' attribute. It lists various HTML server controls and provides an example of using an HTML table for layout with input fields and a button to display user data. The document emphasizes the use of standard HTML tags alongside server-side processing for dynamic content display.

Uploaded by

Gokul Sundaram
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

ASP.net - HTML Server

The document explains HTML server controls in ASP.NET, which are standard HTML controls enhanced for server-side processing by adding the 'runat="server"' attribute. It lists various HTML server controls and provides an example of using an HTML table for layout with input fields and a button to display user data. The document emphasizes the use of standard HTML tags alongside server-side processing for dynamic content display.

Uploaded by

Gokul Sundaram
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Page 1 of 7

Home Whiteboard Online Compilers Practice Articles Tools

[Link] - HTML Server

The HTML server controls are basically the standard HTML controls enhanced to enable
server side processing. The HTML controls such as the header tags, anchor tags, and
input elements are not processed by the server but are sent to the browser for display.

They are specifically converted to a server control by adding the attribute runat="server"
and adding an id attribute to make them available for server-side processing.

For example, consider the HTML input control:

<input type="text" size="40">

It could be converted to a server control, by adding the runat and id attribute:

<input type="text" id="testtext" size="40" runat="server">

Advantages of using HTML Server Controls


Although [Link] server controls can perform every job accomplished by the HTML
server controls, the later controls are useful in the following cases:

Using static tables for layout purposes.

Converting a HTML page to run under [Link]

The following table describes the HTML server controls:

Control Name HTML tag

HtmlHead <head>element

HtmlInputButton <input type=button|submit|reset>


Page 2 of 7

HtmlInputCheckbox <input type=checkbox>

HtmlInputFile <input type = file>

HtmlInputHidden <input type = hidden>

HtmlInputImage <input type = image>

HtmlInputPassword <input type = password>

HtmlInputRadioButton <input type = radio>

HtmlInputReset <input type = reset>

HtmlText <input type = text|password>

HtmlImage <img> element

HtmlLink <link> element

HtmlAnchor <a> element

HtmlButton <button> element

HtmlButton <button> element

HtmlForm <form> element

HtmlTable <table> element

HtmlTableCell <td> and <th>

HtmlTableRow <tr> element

HtmlTitle <title> element

HtmlSelect <select&t; element

HtmlGenericControl All HTML controls not listed

Example
The following example uses a basic HTML table for layout. It uses some boxes for getting
input from the users such as name, address, city, state etc. It also has a button control,
which is clicked to get the user data displayed in the last row of the table.

The page should look like this in the design view:


Page 3 of 7

The code for the content page shows the use of the HTML table element for layout.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"


Inherits="htmlserver._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"[Link]

<html xmlns="[Link] >

<head runat="server">
<title>Untitled Page</title>

<style type="text/css">
.style1
{
width: 156px;
}
.style2
{
width: 332px;
}
</style>

</head>

<body>
<form id="form1" runat="server">
<div>
<table style="width: 54%;">
<tr>
<td class="style1">Name:</td>
<td class="style2">
<asp:TextBox ID="txtname" runat="server"
Page 4 of 7

style="width:230px">
</asp:TextBox>
</td>
</tr>

<tr>
<td class="style1">Street</td>
<td class="style2">
<asp:TextBox ID="txtstreet" runat="server"
style="width:230px">
</asp:TextBox>
</td>
</tr>

<tr>
<td class="style1">City</td>
<td class="style2">
<asp:TextBox ID="txtcity" runat="server"
style="width:230px">
</asp:TextBox>
</td>
</tr>

<tr>
<td class="style1">State</td>
<td class="style2">
<asp:TextBox ID="txtstate" runat="server"
style="width:230px">
</asp:TextBox>
</td>
</tr>

<tr>
<td class="style1"> </td>
<td class="style2"></td>
</tr>

<tr>
<td class="style1"></td>
<td ID="displayrow" runat ="server" class="style2">
</td>
</tr>
Page 5 of 7

</table>

</div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Click" />
</form>
</body>
</html>

The code behind the button control:

protected void Button1_Click(object sender, EventArgs e)


{
string str = "";
str += [Link] + "<br />";
str += [Link] + "<br />";
str += [Link] + "<br />";
str += [Link] + "<br />";
[Link] = str;
}

Observe the following:

The standard HTML tags have been used for the page layout.

The last row of the HTML table is used for data display. It needed server side
processing, so an ID attribute and the runat attribute has been added to it.

TOP TUTORIALS
Chapters Categories
Python Tutorial

Java Tutorial
C++ Tutorial

C Programming Tutorial

C# Tutorial
PHP Tutorial

R Tutorial

HTML Tutorial

You might also like