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

 

<%@ 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>&nbsp;</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>&nbsp;</td>");
                  }
              }
              Response.Write("</tr>");
          }
           %>
      </table>
    
    </div>
    </form>
</body>
</html>

 

 

posted @ 2013-09-23 11:11  笨笨丫头~双  阅读(275)  评论(0编辑  收藏  举报