HTML server controls are HTML elements that contain attributes accessible to the server-side. We can convert HTML events to server elements by adding runat= “server” and id attributes.
Example –
<asp:Label ID="lablemessage" runat="server" >
Examples
Code – //HTMLhandlingcontrol.aspx
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HTMLhandlingcontrol.aspx.cs" Inherits="Demo_1.HTMLhandlingcontrol" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 108px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" runat="server"/>
<asp:Button ID="btnclick" runat="server" Text="Click" onclick="butttonclick" />
</div>
</form>
</body>
</html>
// HTMLhandlingcontrol.aspx.cs
Code –
The application consist of behind file on // HTMLhandlingcontrol.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Demo_1
{
public partial class HTMLhandlingcontrol : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void button click(object sender, EventArgs e)
{
string a = Request.Form["Text1"];
Response.Write(a);
}
}
}