TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

ASP.Net HTML Server Controls

ASP.Net Html Server Controls with asp.net tutorial, asp.net introduction, features, project, example, server controls, labels, textbox, button, hyperlink, radiobutton, calender, checkbox, fileupload, events handling, authentication, webforms model binding, html server control, compare validdator, range validator, validation summary, mvc introduction, mvc project, view, validation, entity framework, authentication etc.

<< Back to ASP

ASP.NET HTML Server Controls

HTML server controls are HTML elements that contain attributes to accessible at server side. By default, HTML elements on an ASP.NET Web page are not available to the server. These components are treated as simple text and pass through to the browser. We can convert an HTML element to server control by adding a runat="server" and an id attribute to the component.

Now, we can easily access it at code behind.

Example

<input id="UserName" type="text" size="50"runat="server" />

All the HTML Server controls can be accessed through the Request object.


HTML Components

The following table contains commonly used HTML components.

Controls Name Description
Button It is used to create HTML button.
Reset Button It is used to reset all HTML form elements.
Submit Button It is used to submit form data to the server.
Text Field It is used to create text input.
Text Area It is used to create a text area in the html form.
File It is used to create a input type = "file" component which is used to upload file to the server.
Password It is a password field which is used to get password from the user.
CheckBox It creates a check box that user can select or clear.
Radio Button A radio field which is used to get user choice.
Table It allows us to present information in a tabular format.
Image It displays an image on an HTML form
ListBox It displays a list of items to the user. You can set the size from two or more to specify how many items you wish to show.
Dropdown It displays a list of items to the user in a dropdown list.
Horizontal Rule It displays a horizontal line across the HTML page.

Example

Here, we are implementing an HTML server control in the form.

// htmlcontrolsexample.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="htmlcontrolsexample.aspx.cs" 
Inherits="asp.netexample.htmlcontrolsexample" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" runat="server"/>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
</div>
</form>
</body>
</html>

This application contains a code behind file.

// htmlcontrolsexample.aspx.cs

using System;
namespace asp.netexample
{
public partial class htmlcontrolsexample : System.Web.UI.Page
    {
protected void Page_Load(object sender, EventArgs e)
        {
        }
protected void Button1_Click(object sender, EventArgs e)
        {
string a = Request.Form["Text1"];
            Response.Write(a);
        }
    }
}

Output:

ASP Server controls 1

When we click the button after entering text, it responses back to client.

ASP Server controls 2




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf