Practical - 02

AIM: Design a web application to add two integer numbers using ASP.Net through C# language.

How to open Visual Studio

Visual Studio Framework

Framework Introduction

Figure 1: Introduction of Visual Studio Framework.

Different Windows in Visual Studio

Solution Explorer: Solution Explorer is a window which shows all the items in your project solution. (Items like all projects, classes, folders etc).

ToolBox: To view the toolbox, select toolbox from the view menu

Proporties Window: Property window is used to change the property of a web form or a control in web form. To view the property window, select property window in view menu.

Web Form: Web form has the extension of .aspx.

Design View of Two Number Addition

Design View

Figure 1: Design view of addition of two numbers.

HTML code of Addition Web Form

HTML Code

Figure 2: HTML code of web form of addition of two numbers.

C# Code

			
protected void Button1_Click(object sender, EventArgs e)
{
	int Var1 = int.Parse(TextBox1.Text);
	int Var2 = int.Parse(TextBox2.Text);
	int Var3 = Var1 + Var2;
	Label1.Text = "Addition is: " + Var3.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
	TextBox1.Text = "";
	TextBox2.Text = "";
	Label1.Text = "";
}
					

Points to Remember:

Type of a text property of any control in ASP is string. Therefore to perform addition, we have converted the string value of TextBox1 and TextBox2 into integer and perform arithmetic operation on it and again convert the final result to string and pass it to Label1.

Theory of Computation AIM 01 Transition Diagram

Prepared By

Piyush Garg,
Asst. Professor,
Department of CSE, CIST
E-mail: piyushgarg1985@yahoo.com