文件:
Calculateaspx
bin/Calculatecs
bin/Calculatebat
步骤:
Calculatecs
namespace Calculate
{
using System;
public class math
{
public String _color;
public int Add(int aint b)
{
return a+b;
}
public int Sub(int aint b)
{
return ab;
}
public int Mul(int aint b)
{
return a*b;
}
public String Color
{
get
{
return _color;
}
set
{
_color=value;
}
}
}
}
Calculatebat
csc /t:library /out:Calculatedll Calculatecs
执行Calculatebat
Calculateaspx
<%@Import NameSpace=Calculate%>
<script language=c# runat=server>
public String color;
void DoAdd(Object Src EventArgs E)
{
math math=new math();
MessageText=mathAdd(ConvertToInt(AValue)ConvertToInt(BValue))ToString();
mathColor=CValue;
color=mathColor;
}
void DoSub(Object Src EventArgs E)
{
math math=new math();
MessageText=mathSub(ConvertToInt(AValue)ConvertToInt(BValue))ToString();
mathColor=CValue;
color=mathColor;
}
void DoMul(Object Src EventArgs E)
{
math math=new math();
MessageText=mathMul(ConvertToInt(AValue)ConvertToInt(BValue))ToString();
mathColor=CValue;
color=mathColor;
}
</script>
<font id=Cau color=<%ResponseWrite(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/>