Professional Documents
Culture Documents
Now have the picture of calculator in your mind. If you do so it is very is to implement your
views with the support given by .NET IDE. What you have to do is just drag and drop.
(i) A Text box to see the values entered and for the output
(ii) Buttons for numbers and operations(+,-,/,*)
That’s all I need. you can add others tools also like link labels.
Now you are in the Design part. In this part you will be creating the view by simply
dragging the tools on to the design page. And you can write a text directly on the page by
clicking on the spot wherever you want to write.
And now you can drag from the tool box and drop it on the design page. See I dragged the text
box and of course I changed its size. When you click on the text box you will find small boxes
on top of the box to change the size.
You can move the box to right, by placing the cursor before it( don’t select it) and press space or
tab.
Similar way I dragged the buttons also. You need not drag all the buttons one by one. You can
copy and paste the buttons there itself.
You can see the properties of button on the right side in Properties Window. If you don’t find go
to View and click on Properties Window.
In that window you can now the details of options alphabetical, events, properties by simply
placing the cursor on the icons.
For Text Box, since you are going to give input using buttons, go to properties of Text box and
change read only option to true.
Now give the values (I mean change the text) to all the buttons.
Now the work is, if you click on a button that value should appear in the text box.
To do this, first double click on the button, and write respective code.
Example:
When I click on the button numbered 1, that number should appear in the text box.
So if I double click on the button I will be redirected to Default.aspx.cs and Straight away my
cursor will be placed in a function button_click(); where I need to write the code when I clicked
on that.
So my code will be
TextBox1.Text = "1";
note: when u click on 2 after 1, it should show 12. So , u need to append here.
1. Whenever a user clicks on any operators, the value in textbox, operator should be saved.
2. And soon after he gave the next value and pressed any other button except numbers it
should do the previous operation and should be ready to go for next operation.
3. Same as calculator in your system
4. Add trigonometric, logarithmic and other scientific calculator operations also.
U can find these trigonometric operations built in the .net IDE. In Math class.
Example: x=Math.Sin(45);
That’s all .
How to execute:
1. F6 (Build Build Solution) to build a solution file ( which has all the details about your
site)
2. The same you can use for checking the errors.
3. F5 ( Debug Start Debugging) to run the code (will be displayed in your default
browser).
Suggestion: You can try the same calculator to develop a system application
After completion Goto Build Publish. You will be having your own setup file for calculator.
You can install in any system.
//Example code for default.aspx.cs page:
using System;
using System.Collections;
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;
namespace Calc
{
public partial class Default : System.Web.UI.Page
{
//global data
int pre_value; //to store previous value
char operation; //to know the operation. I have not used. But u require this.
protected void Page_Load(object sender, EventArgs e)
{