Asp Net Sample Programs Using C#
ASP.NET basic calculatorASP.NET Basic calculatorIn this first example project, you will do simple things with ASP.NET controls, and events by building a basic calculator to sum two numbers. You will need one textbox (txtinput) to display the numbers and result, two hidden text boxes to store the numbers entered by the user, ten buttons to label numbers from 0 to 9 (bnt0 to bnt9), and the other three buttons to sum, show the result, and to clear text from the result textbox.Each button is attached with a procedure to perform action when it is clicked. For example, when you click a button labeled 0, the value 0 will be displayed in the textbox. To allow a button to perform action when it is clicked, you need to attach the function name to the OnClick event of the button.Example:When a number button is clicked, the number is appended to the text box value by using string concatenation operator (&). By doing this, the old numerical character is not replaced by the new character.
Asp.net Example Programs In C#
The Text property of a text box control allows you to read and write value to the textbox.Example:txtinput.Text=txtinput.Text & btn0.TextThe number in the text box is a string value. To be able to sum the values together, you need to convert the sting value to a number.Example:dim result=CDbl(val1.Text)+CDbl(val2.Text)This expression converts the values of val1 and val2 text boxes to floating-point numbers that can be used in the calculation.Each ASP.NE control to be placed on the page must specify runat='server'.