用C# ASP.NET编写九九乘法表。。。
在Asp网页中,要求用户输入一个开始值和结束值,网页下面的label上会显示从开始值到结束值之间的九九乘法表。。求高手。,...
在Asp网页中,要求用户输入一个开始值和结束值,网页下面的label上会显示从开始值到结束值之间的九九乘法表 。。求高手。,
展开
1个回答
2013-06-30
展开全部
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestWebApp.WebForm1" %><!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>
开始:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
结束:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<hr />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
int n1 = Convert.ToInt32(TextBox1.Text);
int n2 = Convert.ToInt32(TextBox2.Text); for (int i = n1; i <= n2; i++)
{
for (int j = 1; j <= i; j++)
{
Label1.Text += " "+j+"*"+i+"="+j*i;
}
Label1.Text += "<br/>";
}
}
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
开始:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
结束:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<hr />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
int n1 = Convert.ToInt32(TextBox1.Text);
int n2 = Convert.ToInt32(TextBox2.Text); for (int i = n1; i <= n2; i++)
{
for (int j = 1; j <= i; j++)
{
Label1.Text += " "+j+"*"+i+"="+j*i;
}
Label1.Text += "<br/>";
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询