Here the code below
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{//addition
int i, j,sum;
string temp,a;
i = int.Parse(finput.Text);
j = int.Parse(linput.Text);
sum = i + j;
temp = Convert.ToString(sum);
a= "The Addition is: ";
Label3.Text = a + temp;
}
protected void Button2_Click(object sender, EventArgs e)
{//substraction
int i, j, sub;
string temp, a;
i = int.Parse(finput.Text);
j = int.Parse(linput.Text);
sub = i - j;
temp = Convert.ToString(sub);
a = "The Subtraction is: ";
Label3.Text = a + temp;
}
protected void Button3_Click(object sender, EventArgs e)
{//multiplication
int i, j, mul;
string temp, a;
i = int.Parse(finput.Text);
j = int.Parse(linput.Text);
mul = i * j;
temp = Convert.ToString(mul);
a = "The Multiplication is: ";
Label3.Text = a + temp;
}
protected void Button4_Click(object sender, EventArgs e)
{//division
int i, j, div;
string temp, a;
i = int.Parse(finput.Text);
j = int.Parse(linput.Text);
div = i / j;
temp = Convert.ToString(div);
a = "The Division is: ";
Label3.Text = a + temp;
}
protected void Button5_Click(object sender, EventArgs e)
{//remainder
int i, j, rem;
string temp, a;
i = int.Parse(finput.Text);
j = int.Parse(linput.Text);
rem = i % j;
temp = Convert.ToString(rem);
a = "The Remainder is: ";
Label3.Text = a + temp;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Basic Calculator</title>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 494px">
<br />
<asp:Label ID="Label1" runat="server" Text="1st Number :"></asp:Label>
<asp:TextBox ID="finput" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="finput" ErrorMessage="You must have to Enter 1st Number"></asp:RequiredFieldValidator>
<br />
<asp:Button ID="Button3" runat="server" onclick="Button3_Click"
style="z-index: 1; left: 312px; position: absolute; top: 128px; width: 50px;"
Text="MUL" />
<asp:Button ID="Button4" runat="server"
style="z-index: 1; left: 400px; position: absolute; top: 127px; height: 26px; width: 48px"
Text="DIV" onclick="Button4_Click" />
<asp:Button ID="Button5" runat="server"
style="z-index: 1; left: 486px; top: 129px; position: absolute; width: 46px;" Text="REM"
onclick="Button5_Click" />
<br />
<asp:Label ID="Label2" runat="server" Text="2nd Number :"></asp:Label>
<asp:TextBox ID="linput" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="top: 128px; left: 129px; position: absolute; height: 26px; width: 52px; z-index: 1;"
Text="ADD" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="linput" ErrorMessage="You must have to Enter 2nd Number"></asp:RequiredFieldValidator>
<br />
<br />
<br />
<br />
<br />
<asp:Label ID="Label3" runat="server"></asp:Label>
<asp:Button ID="Button2" runat="server"
style="z-index: 1; left: 217px; top: 128px; position: absolute; width: 52px; right: 530px;"
Text="SUB" onclick="Button2_Click" />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
No comments:
Post a Comment