<html>
 <head>
 <title>第七例 HtmlForm和HtmlGenericControl控件使用</title>
 
    <script language="C#" runat="server">
        void Button1_OnClick(object Source, EventArgs e) 
       {
	  Body.Attributes["bgcolor"] = ColorSelect.Value;	//改变背景颜色
          Span1.InnerHtml="你点击的是按钮1，背景颜色改变为:"+ColorSelect.Value;
          Span2.InnerHtml="";
          Span3.InnerHtml="";
//此处将Span2、3的值清空，而Span1的值为提示信息，其他按钮相同
       }
        void Button2_OnClick(object Source, EventArgs e) 
       {
	  Body.Attributes["bgcolor"] = ColorSelect.Value;
          Span1.InnerHtml="";
          Span2.InnerHtml="你点击的是按钮2，背景颜色改变为:"+ColorSelect.Value;
          Span3.InnerHtml="";
       }
        void Button3_OnClick(object Source, EventArgs e) 
       {
	  Body.Attributes["bgcolor"] = ColorSelect.Value;
          Span1.InnerHtml="";
          Span2.InnerHtml="";
          Span3.InnerHtml="你点击的是按钮3，背景颜色改变为:"+ColorSelect.Value;
       }
     </script>
 
 </head>
 
 <body id=Body runat=server>  <!-- 注意body已经被定义为Html控件 -->
     <h3><font face="Verdana">HtmlForm及HtmlGenericControl实例</font></h3>
     <form id="ServerForm" runat="server">
    选择一种背景颜色：
    <p>
       <select id="ColorSelect" runat="server">
           <option>White</option>
           <option>LightBlue</option>
	      <option Selected>Gray</option>
	      <option>Green</option>
           <option>LightGreen</option>
           <option>Yellow</option>
	   <option>Red</option>
       </select>
    </p>
           <button id="Button1"
               OnServerClick="Button1_OnClick" 
               runat="server">
           按钮1
           </button>
        &nbsp;&nbsp;
        <span id="Span1" runat="server"/><!-- 此处Span同样也是HtmlGenericControl控件 -->
<p>
        <button id="Button2"
               OnServerClick="Button2_OnClick" 
               runat="server">
                 按钮2
        </button>
        &nbsp;&nbsp;
        <span id="Span2" runat="server"/>
        <p>
        <button id="Button3" 
               OnServerClick="Button3_OnClick"
               runat="server">
           按钮3
        </button>
        &nbsp;&nbsp;
        <span id="Span3" runat="server"/>
     </form>

  </body>
</html>
