ASP.NET菜鸟问题
我刚开始学,用的vs2010(还不太会用),想做一个网页计算器,代码如下,但是运行之后得不到结果,不知为何……请各位高手帮忙指点指点吧~谢谢!<%@PageTitle="...
我刚开始学,用的vs2010(还不太会用),想做一个网页计算器,代码如下,但是运行之后得不到结果,不知为何…… 请各位高手帮忙指点指点吧~ 谢谢!
<%@ Page Title="Simple Calculator" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="X-Large"
Text="The Simple Calculator"></asp:Label>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="First Number"></asp:Label>
<asp:TextBox ID="txtNumber1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Second Number"></asp:Label>
<asp:TextBox ID="txtNumber2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnAdd" runat="server" Text="Add" />
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="The answer is :"></asp:Label>
<asp:TextBox ID="txtAnswer" runat="server" ReadOnly="True"></asp:TextBox>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
decimal num1 = Decimal.Parse(txtNumber1.Text);
decimal num2 = Decimal.Parse(txtNumber2.Text);
decimal ans = num1 + num2;
txtAnswer.Text = ans.ToString();
}
} 展开
<%@ Page Title="Simple Calculator" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="X-Large"
Text="The Simple Calculator"></asp:Label>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="First Number"></asp:Label>
<asp:TextBox ID="txtNumber1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Second Number"></asp:Label>
<asp:TextBox ID="txtNumber2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnAdd" runat="server" Text="Add" />
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="The answer is :"></asp:Label>
<asp:TextBox ID="txtAnswer" runat="server" ReadOnly="True"></asp:TextBox>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
decimal num1 = Decimal.Parse(txtNumber1.Text);
decimal num2 = Decimal.Parse(txtNumber2.Text);
decimal ans = num1 + num2;
txtAnswer.Text = ans.ToString();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询