求在ASP.NET中用C#写一个简单的页面计算器!
3个回答
推荐于2018-05-07
展开全部
文件:
Calculate.aspx
bin/Calculate.cs
bin/Calculate.bat步骤:
1.Calculate.csnamespace Calculate
{
using System;
public class math {public String _color;
public int Add(int a,int b)
{
return a+b;
}public int Sub(int a,int b)
{
return a-b;
}public int Mul(int a,int b)
{
return a*b;
}
public String Color
{
get {
return _color;
}
set {
_color=value;
}
}}
}2.Calculate.batcsc /t:library /out:Calculate.dll Calculate.cs3.执行Calculate.bat4.Calculate.aspx
<%@Import NameSpace="Calculate"%><script language="c#" runat="server">
public String color;
void DoAdd(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Add(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}void DoSub(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Sub(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;
}void DoMul(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Mul(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}</script>
<font id=Cau color=<%Response.Write(color);%>>用ASP+写得简易计算器</font>
<form runat="server"><input id="A" runat="server"/>
<input id="B" runat="server"/>
<input id="C" runat="server"/>
<asp:button Text="Add" OnClick="DoAdd" runat="server"/>
<asp:button Text="Sub" OnClick="DoSub" runat="server"/>
<asp:button Text="Mul" OnClick="DoMul" runat="server"/>
</form>
Result:<asp:label id=Message runat="server"/>文件:
Calculate.aspx
bin/Calculate.cs
bin/Calculate.bat步骤:
1.Calculate.csnamespace Calculate
{
using System;
public class math {public String _color;
public int Add(int a,int b)
{
return a+b;
}public int Sub(int a,int b)
{
return a-b;
}public int Mul(int a,int b)
{
return a*b;
}
public String Color
{
get {
return _color;
}
set {
_color=value;
}
}}
}2.Calculate.batcsc /t:library /out:Calculate.dll Calculate.cs3.执行Calculate.bat4.Calculate.aspx
<%@Import NameSpace="Calculate"%><script language="c#" runat="server">
public String color;
void DoAdd(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Add(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}void DoSub(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Sub(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;
}void DoMul(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Mul(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}</script>
<font id=Cau color=<%Response.Write(color);%>>用ASP+写得简易计算器</font>
<form runat="server"><input id="A" runat="server"/>
<input id="B" runat="server"/>
<input id="C" runat="server"/>
<asp:button Text="Add" OnClick="DoAdd" runat="server"/>
<asp:button Text="Sub" OnClick="DoSub" runat="server"/>
<asp:button Text="Mul" OnClick="DoMul" runat="server"/>
</form>
Result:<asp:label id=Message runat="server"/>
Calculate.aspx
bin/Calculate.cs
bin/Calculate.bat步骤:
1.Calculate.csnamespace Calculate
{
using System;
public class math {public String _color;
public int Add(int a,int b)
{
return a+b;
}public int Sub(int a,int b)
{
return a-b;
}public int Mul(int a,int b)
{
return a*b;
}
public String Color
{
get {
return _color;
}
set {
_color=value;
}
}}
}2.Calculate.batcsc /t:library /out:Calculate.dll Calculate.cs3.执行Calculate.bat4.Calculate.aspx
<%@Import NameSpace="Calculate"%><script language="c#" runat="server">
public String color;
void DoAdd(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Add(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}void DoSub(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Sub(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;
}void DoMul(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Mul(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}</script>
<font id=Cau color=<%Response.Write(color);%>>用ASP+写得简易计算器</font>
<form runat="server"><input id="A" runat="server"/>
<input id="B" runat="server"/>
<input id="C" runat="server"/>
<asp:button Text="Add" OnClick="DoAdd" runat="server"/>
<asp:button Text="Sub" OnClick="DoSub" runat="server"/>
<asp:button Text="Mul" OnClick="DoMul" runat="server"/>
</form>
Result:<asp:label id=Message runat="server"/>文件:
Calculate.aspx
bin/Calculate.cs
bin/Calculate.bat步骤:
1.Calculate.csnamespace Calculate
{
using System;
public class math {public String _color;
public int Add(int a,int b)
{
return a+b;
}public int Sub(int a,int b)
{
return a-b;
}public int Mul(int a,int b)
{
return a*b;
}
public String Color
{
get {
return _color;
}
set {
_color=value;
}
}}
}2.Calculate.batcsc /t:library /out:Calculate.dll Calculate.cs3.执行Calculate.bat4.Calculate.aspx
<%@Import NameSpace="Calculate"%><script language="c#" runat="server">
public String color;
void DoAdd(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Add(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}void DoSub(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Sub(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;
}void DoMul(Object Src, EventArgs E)
{
math math=new math();
Message.Text=math.Mul(Convert.ToInt32(A.Value),Convert.ToInt32(B.Value)).ToString();
math.Color=C.Value;
color=math.Color;}</script>
<font id=Cau color=<%Response.Write(color);%>>用ASP+写得简易计算器</font>
<form runat="server"><input id="A" runat="server"/>
<input id="B" runat="server"/>
<input id="C" runat="server"/>
<asp:button Text="Add" OnClick="DoAdd" runat="server"/>
<asp:button Text="Sub" OnClick="DoSub" runat="server"/>
<asp:button Text="Mul" OnClick="DoMul" runat="server"/>
</form>
Result:<asp:label id=Message runat="server"/>
2013-09-26
展开全部
解决这个问题与ASP.NET没有直接关系。我要说的是,如果我们设计的东西不需要与服务器端交互,则直接在客户端处理。这个问题完全可以由 Html + javascript 解决!如果客户端的呈现 依赖与服务端的行为则采用与服务端的交互..
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-09-26
展开全部
课后作业 自己做白, 你可以参考一下 ASP.NET技术大全
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询