您的位置:首页 > 其它

用Response对象的write方法和<%%>及<%=%>输出同样效果的乘法表格

2013-09-23 11:11 120 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Response1.aspx.cs" Inherits="WebApplication1.Response1" %>

<!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>
<table border="1" width="600px">
<tr><th colspan="9">九九乘法表</th></tr>
<%
for (int i = 1; i < 10; i++)
{
%>
<tr>
<%
for (int j = 1; j < 10; j++)//输出一行的每列
{
if (j <= i)
{//如果没内容
%>
<td><%=j%>*<%=i%>=<%=i * j%></td>
<% }
else
{//否则输出空单元格
%>
<td> </td>
<% }
} %>
</tr>
<%
}
%>
</table>
</div>
</form>
</body>
</html>


-------------------------------------------------------------用<%%>和<%=%>输出的--------------------------------------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Response.aspx.cs" Inherits="WebApplication1.Response" %>

<!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>用Response对象的Write方法<% %></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" width="600px">
<tr><th colspan="9">九九乘法表</th></tr>
<%
for (int i = 1; i < 10; i++)
{
Response.Write("<tr>");
for (int j = 1; j < 10; j++)//输出一行中的每列
{
if (j <= i)
{//如果没有内容
Response.Write(string.Format("<td>{0}*{1}={2}</td>", j, i, j * i));
}
else
{//否则输出空格
Response.Write("<td> </td>");
}
}
Response.Write("</tr>");
}
%>
</table>

</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐