webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="work008.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>用Response输出九九乘法表</title>
<!-- 前端页面如何使用< % % >编写脚本代码 -->
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" style="width:100%;">
<tr>
<th colspan="9">九九乘法表</th>
</tr>
<%
for (int row = 1; row < 10; row++)
{
Response.Write("<tr>");
for (int col = 1; col < 10; col++)
{
if (col <= row)
{
Response.Write(string.Format("<td>{0} * {1} = {2}</td>", col, row, col * row));
}
else
{
Response.Write("<td> </td>");
}
}
Response.Write("</tr>");
}
%>
</table>
</div>
</form>
</body>
</html>
webform2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="work008.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>九九乘法表</title>
<!--如何使用 < % = % >符号,来写前端代码,此种方式asp用的较多,类似php编写,但是说实话,在asp.net中
没人会写如此晦涩难懂的程序,除非头不合适。-->
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" style="width:100%;">
<tr>
<th colspan="9">九九乘法表</th>
</tr>
<% for (int row = 1; row < 10; row++){ %>
<tr>
<%
for (int col = 1; col < 10; col++)
{
if(col <= row)
{
%>
<td><%=col %> * <%=row %> = <%=col*row %></td>
<%
}
else
{
%>
<td><%= " " %></td>
<%
}
}
}
%>
</tr>
</table>
</div>
</form>
</body>
</html>