• HTMl服务器控件和WEB服务器控件(二)


    HtmlControl

    所有的HTMl服务器控件都继承自HtmlControl类。该类分为三种类型:

    HtmlInputControl(输入控件)

    HtmlContainerControl(容器控件)

    HtmlImage(图片控件)

    HtmlControl继承自System.Web.UI.Control类,该类是所有ASP.NET中服务器中的基类,System.Web.Control继承自.NET所有对象的基类System.Objecet

     HtmlContainerControl基类:所有成对标签继承与它,它本身派生于HtmlControl,  属性中最重要的是InnerHtml和InnerText用于指定对标签控件

     HtmlGenericControl类:<meta><p><span><link><style>这样的标签使用该类进行服务器端访问,这些类并没有传统面向对象的属性,有一个Attributes集合可以让我操作属性

     示例:

    <%@ Page Language="C#"%>
    <script runat="server">
     protected void Page_Load(object sender, EventArgs e)
        {
            MetaTest.Attributes["name"] = "description";
            MetaTest.Attributes["content"] = "Generated on:" + DateTime.Now.ToString();
        }
    </script>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta id="MetaTest" runat="server" />
        <title>Using the HtmlGenericControl class</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        The rain in Spain stays mainly in the plains.
        </div>
        </form>
    </body>
    </html>

    运行后在网页中点击右键查看源文件:

    <head><meta id="MetaTest" name="description" content="Generated on:2009-12-24 20:40:18" />

    <title>
     Using the HtmlGenericControl class
    </title></head>

    这是可以看到代码,HtmlGenericControl修改了页面中的<meta>元素

    Web服务器控件:

    例如:TextBox\Button\Lable...

    不同的浏览器版本请求同一个页面,那么可能每个得到的HTML输出不同,可以处理常见的WEB页面窗体元素(如文本框和按钮)

     还可以增加一些高级功能(如日历)

      

  • 相关阅读:
    AcWing 900. 整数划分
    AcWing 913. 排队打水
    AcWing 897. 最长公共子序列
    AcWing 895. 最长上升子序列
    AcWing 902. 最短编辑距离
    AcWing 338. 计数问题
    AcWing 896. 最长上升子序列 II
    AcWing 779. 最长公共字符串后缀
    AcWing 282. 石子合并
    ASP.NET里常用的JS (转贴)
  • 原文地址:https://www.cnblogs.com/scsuns520/p/1631009.html
Copyright © 2020-2023  润新知