ASP.NET Tutorial/HTML Controls/Introduction

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Important HTML Control Properties

Control               Most Important Properties
HtmlAnchor            HRef, Name, Target, Title
HtmlImage             Src, Alt, Align, Border, Width, Height
HtmlInputCheckBox     Checked
HtmlInputRadioButton  Checked
HtmlInputText         Value
HtmlTextArea          Value
HtmlInputImage        Src, Alt, Align, Border
HtmlSelect            Items (collection)
HtmlGenericControl    InnerText and InnerHtml


Use the ServerChange event for HTML controls

<%@ Page Language="C#" %>
<script runat="server">
public void DetectChange(object sender, EventArgs e) 
{
    HtmlInputCheckBox cb = (HtmlInputCheckBox) sender;
    Response.Write("Control <b>" + cb.UniqueID + "</b> changed<br>");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Server changes</title>
</head>
<body>
    <div id="pageContent">
        <form id="Form1" runat="server">
            <input runat="server" type="checkbox" id="one" 
                onserverchange="DetectChange" />One<br />
            <input runat="server" type="checkbox" id="two" 
                onserverchange="DetectChange" />Two<br />
            <input runat="server" type="checkbox" id="three" 
                onserverchange="DetectChange" />Three<br />
            <input runat="server" type="submit" value="Submit" />
        </form>
    </div>
</body>
</html>


Which controls provide a ServerClick event and which ones provide a ServerChange event.

Event             Controls That Provide It
ServerClick       HtmlAnchor, HtmlButton, HtmlInputButton, HtmlInputImage, HtmlInputReset
ServerChange      HtmlInputText, HtmlInputCheckBox, HtmlInputRadioButton, HtmlInputHidden, HtmlSelect, HtmlTextArea