ASP.NET Server control events

ASP.NET server controls, Like as  Button, TextBox and DropDownList etc has their own events. For example,Button has a click event. TextBox has TextChanged event, and DropDownList has SelectedIndexChanged event. We have a set of asp.net validation controls, that has validation events. the users can enter data, make selections and indicate their preferences

ASP.NET uses five types of web controls, which are:
•HTML controls
•HTML Server controls
•ASP.NET Server controls
•ASP.NET Ajax Server controls
•User controls and custom controls

HTML Controls
he following controls, which are based on the HTML INPUT element, are available on the HTML tab of the Toolbox: Input (Button) control: INPUT type="button" element. Input (Checkbox) control: INPUT type="checkbox" element

In the following example 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
     First name:<br>
     <input type="text" name="firstname">
    <br>
     Last name:<br>
    <input type="text" name="lastname">
    </form>
</body>

</html>

This is how the HTML code above will be displayed in a browser:
First name:

Last name:



following controls, which are based on the HTML INPUT element, are available on the HTML tab of the Toolbox


Input (Button) control: INPUT type="button" element
Input (Checkbox) control: INPUT type="checkbox" element
Input (File) control: INPUT type="file" element
Input (Hidden) control: INPUT type="hidden" element
Input (Password) control: INPUT type="password" element
Input (Radio) control: INPUT type="radio" element
Input (Reset) control: INPUT type="reset" element
Input (Submit) control: INPUT type="submit" element
Input (Text) control: INPUT type="text" element

HTML server controls 

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

Html Control is
<input type="text" name="firstname">
converted to a server control, by adding the runat=”server”.
<input type="text" name="firstname" runat="server">


Control Name
HTML tag
HtmlHead
<head>element
HtmlInputButton
<input type=button|submit|reset>
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

ASP.NET Server Controls
ASP.NET - HTML Server Controls. HTML server controls are HTML tags understood by the server.
HTML elements in ASP.NET files are, by default, treated as text. To make these elements programmable, add a runat="server" attribute to the HTML element.

In the following example
    <form id="form1" runat="server">
        <table class="auto-style1">
            <tr>
                <td></td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
                <td></td>
            </tr>
            <tr>
            </tr>
        </table>
    </form>




No comments:

Post a Comment