In this lab, you will: Use Session object / variables; Gain experience with PostBack; Create and use several functions called from the web form; And pass parameters to functions.
- Create a single digit calculator
- This lab is not about creating a calculator, as you will see. This lab is about event handlers and learning how to use the source/sender that is passed as a parameter into the event handler. You will also learn about the Convert class and how handy it is.
- Create an aspx with a simple, single-digit integer calculator like this one.
- It must have buttons for 0 - 9; buttons for +, -, *, /, and =; and a button to clear the display
- It must have a display for the number typed and the result
- The button controls use <asp:Button>
- The display control uses <asp:TextBox>
- The label control at the top uses <asp:Label>
- Create functions for the buttons as necessary for event handling
- Create at least one function that (a) you call from within an event handling function and (b) accepts a parameter. For instance, you may create a function that simply stores the value currently displayed by passing in that value as a parameter. The example I use is a function called StoreDisplay()
- Use the Session object to store variables as necessary. It takes the form: Session["whatever"] = "";
- It does not have to accept multi-digit numbers.
- It does not have to accept decimal number, nor calculate decimal numbers. For testing, as an example, use 8/4 (an integer value) and not 8/5 (a decimal value).
- It does not have to continue using the sum stored in the display after the first calculation, i.e.: 3*2=6 *2. It only has to perform the first operation: 3*2=6
- It does not have to have a memory recall nor any scientific calculations.
- Code:
Grading
Does it work |
5 pts |
Coding |
3 pts |
Aesthetics |
2 pts |
Total |
10 pts |
|