VS.NET(C#-2.5)_简单例子(所有控件都转换成HTML控件)

简单例子

UI设计视图

   

 UI代码视图

<% @PageLanguage="C#" AutoEventWireup="true"CodeFile="Default.asp.cs" Inherits="_Default" %>

<!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">    

<title>无标题页</title>

</head>

<body>   

    <form id="form1" runat="server">    

    <div>         

    <h1>

                ASP.NET Server Controls                          

          </h1>

         <h2>

                The date and Time is

                <%=DateTime.Now.ToString() %>

         </h2>

   <p>
            &nbsp;
         </p>

   <p>
           <asp:TextBox ID="txtBookName" runat="Server" Text="Enter a Book Name"></asp:TextBox>
                &nbsp;
         </

         
          <p>
           < asp:Button ID="btnBookName" runat="Server" Text="Book Name"   OnClick="btnBookName_Click1"/>

      &nbsp;
        </p>
         
       <p>
           <asp:Label ID="lblBookName" runat="Server" ></asp:Label>

      &nbsp;
         </p>

        </div>    

  </form>

</body>

</html>

UI服务器端代码视图

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page

{    

   protected void Page_Load(object sender, EventArgs e)    

  {

     }      

  protected void btnBookName_Click1(object sender, EventArgs e)  

    {       

     lblBookName.Text = txtBookName.Text;   

    }

}

UI浏览器运行效果

浏览器页面代码(HTML代码)

 注:上述所有控件都转换成HTML控件。

原文地址:https://www.cnblogs.com/ximi07/p/10881828.html