VS.NET(C#)-2.5_简单例子(所有控件都转换成 HTML控件)
简单例子
UI设计视图
UI代码视图
<%@ PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.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>
</p>
<p>
<asp:TextBox ID="txtBookName" runat="server" Width="250px">Enter a book name</asp:TextBox> </p>
<p>
<asp:Button ID="btnBookName" runat="server" Text="Book Name" OnClick="btnBookName_Click" /> </p>
<p>
<asp:Label ID="lblBookName" runat="server"></asp:Label> </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;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(objectsender, EventArgs e)
{
}
protected void btnBookName_Click(objectsender, EventArgs e)
{
lblBookName.Text = txtBookName.Text;
}
}
UI浏览器运行效果
按照下述操作
浏览器页面代码(HTML代码)
<!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><title>
默认模板代码
</title></head>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTk1NTc5MjE0OWRkPF62ccx1BdaZqBQNax6JD4IFeVQ="/>
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"value="/wEWAwKSvvXsCAKe8vzpDAKG1LbDDdFrBkHZ8GLrq9wyfZYT/ht3RDkS"/>
</div>
<div>
<h1>
ASP.NET ServerControls
</h1>
<h2>
The date and Timeis2018/2/17 上午 10:48:27
</h2>
<p>
</p>
<p>
<input name="txtBookName"type="text"value="Enter abook name" id="txtBookName" style="width:250px;" /> </p>
<p>
<input type="submit"name="btnBookName"value="BookName" id="btnBookName"/> </p>
<p>
<span id="lblBookName"></span> </p>
</div>
</form>
</body>
</html>
上述所有控件都转换成HTML控件