how to create a calculator in asp.net web page :

Abhishek_Maurye
Posted by Abhishek_Maurye under ASP.NET category on | Points: 40 | Views : 3196
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 Button1_Click(object sender, EventArgs e)
{
if (valuebox1.Text.Length > 0 && valuebox2.Text.Length > 0)
{

double result = 0;

double value1 = Convert.ToDouble(valuebox1.Text);

double value2 = Convert.ToDouble(valuebox2.Text);



switch (DropDownList1.SelectedValue)
{

case "+":

result = value1 + value2;

break;

case "-":

result = value1 - value2;

break;

case "*":

result = value1 * value2;

break;

case "/":

result = value1 / value2;

break;

}

output.Text = result.ToString();

}

else
{

output.Text = string.Empty;

}
}
}

Comments or Responses

Login to post response