Practical 1(a): Create an application that obtains four int values from the user and displays the product in ASP.NET with C#.
BSc IT Sem 5- Advanced Web Programming Practicals...
This tutorial provides solutions and step-by-step guidance for practical questions of Advanced Web Programming subject of BSc IT semester 5(Mumbai University). This tutorial will be providing solutions for every practical questions in the syllabus. This blog contains the solution for practical 1(a) question.
Follow the below steps to solve the first practical.
Step 1:
- Open Visual Studio. I am using Microsoft`s Visual Studio 2022, you can use any latest versions.
- Click on "Create a new project".
Step 2:
- Choose language as "C#".
- Choose the operating system which you are using, i`m using Windows OS so I have selected "Windows".
- Choose "web".
- Now look for "ASP.NET Web Application(.NET Framework)".
- Click "Next".
Step 3:
Step 4:
Your Project named "pract1a" is created.
This is the page you will see....
Step 5:
- Right Click on "pract1a" present in the "Solution Explorer" window on the right side of the screen.
- Click on "Add".
- Click "New Item".
- Select "Web Form" and click "Add".
Now a default Web Form page is generated named "WebForm1.aspx". Here you can design the front-end of your practical.
You can design either by using the ToolBox to drag and drop any control you want or by simply writing the HTML code. I will be using toolbox to drag and drop controls on my design page.
Step 6:
- Open "Design" page.
- Click on <body> tag, <div> tag appears, designing is done in the "div" tag.
- You need 4 TextBoxes, 2 Buttons and 1 Label. Drag these controls from "ToolBox" and drop them inside the <div> tag as shown below.
After the designing part is done, now we need to write program in order to use the design and get proper output.
Step 7:
- Single left click on the first button.
Now the "Properties" window appears. The ID of this button is Button1. Search for "text" inside the Properties window and rename it as "Result" and click enter. Name of the button is replaced by "Result" on design page.
- Single left click on the second button -- Properties window -- rename "text" to "Reset" and click enter.
- Single left click on Label -- Properties window -- Delete the given "text" and keep the "text" as blank and click enter.
Step 8:
- Double click on "Result" button on the design page(WebForm1.aspx).
- A new page "WebForm1.aspx.cs". Visual Studio generates all the required code automatically. We just need to write the code for the Buttons.
- Inside the "protected void Button1_Click(object sender, EventArgs e)" method ,write the following code:
int a;
a = Convert.ToInt32(TextBox1.Text) * Convert.ToInt32(TextBox2.Text) *
Convert.ToInt32(TextBox3.Text) * Convert.ToInt32(TextBox4.Text);
Label1.Text ="Result:"+ a.ToString();
- Go back to "WebForm1.aspx" page(design page).
- Double click on "Reset" button.
- Inside the "protected void Button2_Click(object sender, EventArgs e)" method, write the following code:
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
Label1.Text = "";
Comments
Post a Comment
If you have any doubts, Please let me know.