Use ASP.net to implement a simple calculator (for beginners)

Source: Internet
Author: User
Tags implement mul tostring

File:
Calculate.aspx
Bin/calculate.cs
Bin/calculate.bat

Steps:
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. Executive 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);%>> simple calculator with asp+ </font>
<form runat= "Server" >

<input id= "A" runat= "Server"/>
<input id= "B" runat= "Server"/>
<input id= "C" runat= "Server"/>
<asp:button text= "ADD" runat= "Server"/>
<asp:button text= "Sub" runat= "Server"/>
<asp:button text= "Mul" runat= "Server"/>
</form>
Result:<asp:label id=message runat= "Server"/>

File:
Calculate.aspx
Bin/calculate.cs
Bin/calculate.bat

Steps:
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. Executive 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);%>> simple calculator with asp+ </font>
<form runat= "Server" >

<input id= "A" runat= "Server"/>
<input id= "B" runat= "Server"/>
<input id= "C" runat= "Server"/>
<asp:button text= "ADD" runat= "Server"/>
<asp:button text= "Sub" runat= "Server"/>
<asp:button text= "Mul" runat= "Server"/>
</form>
Result:<asp:label id=message runat= "Server"/>

Turn from: Dynamic Network production guide www.knowsky.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.