动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   .Net → 阅读文章

 用ASP.NET实现一个简单的计算器

作者来源: 
阅读 1764 人次 , 2006-3-29 4:33:00 


文件:
calculate.aspx
bin/calculate.cs
bin/calculate.bat

步骤:
1.calculate.cs

namespace 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.bat

csc /t:library /out:calculate.dll calculate.cs

3.执行calculate.bat

4.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.cs

namespace 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.bat

csc /t:library /out:calculate.dll calculate.cs

3.执行calculate.bat

4.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"/>

 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:ASP.NET结合存储过程写的通用搜索分页程序
· 下一篇:隨心所欲產生圖案
· 系结至DataView
· 在ASP+ 中我们如何使用 Class 而不是组件
· Project级别的权限控制
· 从资料源取回第二个DataTable
· ASP.NET的Web controls(一)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077