Question
In C# I need to Create a new WEB SITE with the following:- Create a webpage that contains server side directives, code declaration blocks, includes
In C# I need to Create a new WEB SITE with the following:-
- Create a webpage that contains server side directives, code declaration blocks, includes and controls.
- Create a simple calculator the contains four labels, three textboxes, six buttons and a list box:
- The first label = enter first number
- The second label= enter second number
- The third label = should display the result
- Four of the buttons should be "+", "-", "*", "/"
- The result textbox should be read only
- The startup page must be named index.
- Display a message indicating cannot divide by when the user click / and there is a zero the in the second box
- Prevent the user from entering text in the number fields
- Create the other two buttons
- store data - The store data will store the results into array
- display data - The display data will display the contents of the array (use 10 for the array size)
I need some help with steps 9 11 on the server side for the C# website.
Heres what I have so far for the C# website and code behind:
Index.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Calculator.Index" %>
Index.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Calculator
{
public partial class Index : System.Web.UI.Page
{
double dec1stNum;
double dec2ndNum;
double decResult;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
//Accepts input from txt1stNum & txt2ndNum
double.TryParse(txt1stNum.Text, out dec1stNum);
double.TryParse(txt2ndNum.Text, out dec2ndNum);
//'Adds the 1st & 2nd numbers & displays the results
decResult = dec1stNum + dec2ndNum;
txtResult.Text = dec1stNum + " + " + dec2ndNum + " = " + decResult;
}
protected void btnSubtract_Click(object sender, EventArgs e)
{
//Accepts input from txt1stNum & txt2ndNum
double.TryParse(txt1stNum.Text, out dec1stNum);
double.TryParse(txt2ndNum.Text, out dec2ndNum);
//Subtracts the 2nd number from the 1st number & displays the results
decResult = dec1stNum - dec2ndNum;
txtResult.Text = dec1stNum + " - " + dec2ndNum + " = " + decResult;
}
protected void btnMultiply_Click(object sender, EventArgs e)
{
//Accepts input from txt1stNum & txt2ndNum
double.TryParse(txt1stNum.Text, out dec1stNum);
double.TryParse(txt2ndNum.Text, out dec2ndNum);
//Multiplies the 1st & 2nd numbers & displays the results
decResult = dec1stNum * dec2ndNum;
txtResult.Text = dec1stNum + " X " + dec2ndNum + " = " + decResult;
}
protected void btnDivide_Click(object sender, EventArgs e)
{
//Accepts input from txt1stNum & txt2ndNum
double.TryParse(txt1stNum.Text, out dec1stNum);
double.TryParse(txt2ndNum.Text, out dec2ndNum);
//Divides the 1st number by the 2nd number & displays the results
decResult = dec1stNum / dec2ndNum;
If dec2ndNum = 0;
Then;
txtResult.Text = dec1stNum + " / " + dec2ndNum + " = " + decResult;
End If;
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started