ASP.NET -- WebForm -- .aspx与.aspx.cs文件

ASP.NET -- WebForm --  .aspx与.aspx.cs文件

1. ASP.NET -- WebForm(C#)文件

.aspx文件:是Html页面,页面的布局,样式在该文件中设计。

.aspx.cs文件:后台代码

.aspx.designer.cs文件:由工具自动生成的代码。

新建一个web窗体页面,在.aspx文件顶部,有下面这样一行代码必不可少:

2. 也可以直接在.aspx文件中直接写C#后台代码,但要写在<% %>中。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>

<!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>my Test Aspx</title>
</head>
<body>
    <p><%Response.Write("Hello World!");%></p>
    <form id="form1" runat="server">
    <div>
        <p><%Response.Write(DateTime.Now.ToLongTimeString());%></p>
    </div>
    </form>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/ChengWenHao/p/AspNetPart2.html