<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style5
{
width: 84px;
}
.style19
{
width: 84px;
height: 53px;
}
.style23
{
width: 84px;
height: 49px;
}
.style27
{
height: 41px;
}
.style29
{
width: 93px;
height: 49px;
}
.style30
{
width: 93px;
height: 53px;
}
.style31
{
width: 93px;
}
.style33
{
width: 97px;
height: 49px;
}
.style34
{
width: 97px;
height: 53px;
}
.style35
{
width: 97px;
}
.style36
{
width: 84px;
height: 52px;
}
.style38
{
width: 93px;
height: 52px;
}
.style39
{
width: 97px;
height: 52px;
}
.style40
{
width: 85px;
height: 52px;
}
.style41
{
width: 85px;
height: 49px;
}
.style42
{
width: 85px;
height: 53px;
}
.style43
{
width: 85px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="height: 233px; width: 473px; margin-right: 0px; margin-bottom: 0px">
<tr><td colspan="5" class="style27">
<asp:TextBox ID="TextBox1" runat="server" Height="49px" Width="468px"></asp:TextBox>
</td>
</tr>
<tr><td class="style36">
<asp:Button ID="Btn7" runat="server" Height="43px" Text="7"
Width="84px" onclick="Btn7_Click" />
</td><td class="style40">
<asp:Button ID="Btn8" runat="server" Height="43px" Text="8"
Width="95px" onclick="Btn8_Click" />
</td><td class="style38">
<asp:Button ID="Btn9" runat="server" Height="43px" Text="9"
Width="88px" onclick="Btn9_Click" />
</td>
<td class="style39">
<asp:Button ID="Btnmod" runat="server" Height="43px" Text="%"
Width="93px" onclick="Btnmod_Click" />
</td>
<td rowspan="4">
<asp:Button ID="Btneql" runat="server" Height="201px" Text="="
Width="79px" onclick="Btneql_Click" />
</td></tr>
<tr><td class="style23">
<asp:Button ID="Btn4" runat="server" Height="43px" Text="4"
Width="84px" onclick="Btn4_Click" />
</td><td class="style41">
<asp:Button ID="Btn5" runat="server" Height="43px" Text="5"
Width="94px" onclick="Btn5_Click" />
</td><td class="style29">
<asp:Button ID="Btn6" runat="server" Height="43px" Text="6"
Width="90px" onclick="Btn6_Click" />
</td>
<td class="style33">
<asp:Button ID="Btndiv" runat="server" Height="43px" Text="/"
Width="93px" onclick="Btndiv_Click" />
</td></tr>
<tr><td class="style19">
<asp:Button ID="Btn1" runat="server" Height="43px" Text="1"
Width="84px" onclick="Btn1_Click" />
</td><td class="style42">
<asp:Button ID="Btn2" runat="server" Height="43px" Text="2"
Width="95px" onclick="Btn2_Click" />
</td><td class="style30">
<asp:Button ID="Btn3" runat="server" Height="43px" Text="3"
Width="89px" onclick="Btn3_Click" />
</td>
<td class="style34">
<asp:Button ID="Btnminus" runat="server" Height="43px" Text="-"
Width="94px" onclick="Btnminus_Click" />
</td></tr>
<tr><td class="style5">
<asp:Button ID="Btn0" runat="server" Height="43px" Text="0"
Width="84px" onclick="Btn0_Click" />
</td><td class="style43">
<asp:Button ID="Btnprm" runat="server" Height="43px" Text="+/-"
Width="95px" onclick="Btnprm_Click" />
</td><td class="style31">
<asp:Button ID="Btndot" runat="server" Height="43px" Text="."
Width="89px" onclick="Btndot_Click" />
</td>
<td class="style35">
<asp:Button ID="Btnplus" runat="server" Height="43px" Text="+"
Width="93px" onclick="Btnplus_Click" />
</td> </tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
public int i;
public Double val1, val2, res;
static int c;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Btn1_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text+"1";
}
protected void Btn2_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text + "2";
}
protected void Btn3_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text + "3";
}
protected void Btn4_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text + "4";
}
protected void Btn5_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
} TextBox1.Text = TextBox1.Text + "5";
}
protected void Btn6_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
} TextBox1.Text = TextBox1.Text + "6";
}
protected void Btn7_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
} TextBox1.Text = TextBox1.Text + "7";
}
protected void Btn8_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text + "8";
}
protected void Btn9_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text + "9";
}
protected void Btn0_Click(object sender, EventArgs e)
{
if (c == 1)
{
TextBox1.Text = "";
c = 0;
}
TextBox1.Text = TextBox1.Text + "0";
}
protected void Btndot_Click(object sender, EventArgs e)
{
TextBox1.Text = TextBox1.Text + ".";
}
protected void Btnplus_Click(object sender, EventArgs e)
{
ViewState[" value1"] = Convert.ToDouble(TextBox1.Text);
TextBox1.Text = " ";
ViewState["j"] = 1;
}
protected void Btnminus_Click(object sender, EventArgs e)
{
ViewState[" value1"] = Convert.ToDouble(TextBox1.Text);
TextBox1.Text = " ";
ViewState["j"] = 2;
}
protected void Btndiv_Click(object sender, EventArgs e)
{
ViewState[" value1"] = Convert.ToDouble(TextBox1.Text);
TextBox1.Text = " ";
ViewState["j"] = 3;
}
protected void Btnmod_Click(object sender, EventArgs e)
{
ViewState[" value1"] = Convert.ToDouble(TextBox1.Text);
TextBox1.Text = " ";
ViewState["j"] = 4;
}
protected void Btneql_Click(object sender, EventArgs e)
{
ViewState[" value2"] = Convert.ToDouble(TextBox1.Text);
i = Convert.ToInt32(ViewState["j"].ToString());
if (i == 1)
res =Convert.ToDouble( ViewState[" value1"].ToString()) +Convert.ToDouble( ViewState[" value2"].ToString());
else if (i == 2)
res = Convert.ToDouble(ViewState[" value1"].ToString()) - Convert.ToDouble(ViewState[" value2"].ToString());
else if (i == 3)
res = Convert.ToDouble(ViewState[" value1"].ToString()) / Convert.ToDouble(ViewState[" value2"].ToString());
else if (i == 4)
res = Convert.ToDouble(ViewState[" value1"].ToString()) % Convert.ToDouble(ViewState[" value2"].ToString());
TextBox1.Text = Convert.ToString(res);
c = 1;
}
protected void Btnprm_Click(object sender, EventArgs e)
{
double t;
t = Convert.ToDouble(TextBox1.Text);
t = t * (-1);
TextBox1.Text = Convert.ToString(t);
}
}

No comments:
Post a Comment