All IT Courses 50% Off
Dotnet Tutorials

ASP.NET First Program

An ASP.NET page consists of a number of server controls, including HTML controls, texts, or images. Any data that is sensitive is always stored in the hidden fields. An ASP.NET page is saved with .aspx extension. It is a server-side file. It is divided into the following core sections:

  • Page Directives: It set up the environment for the page to run. The @Page directive contains page-specific attributes that are used by parser and compiler. It specifies how the page should be processed.
  • Code Section: It contains the handlers and control events required by the page. The page code is precompiled and deployed in the form of binary assembly.
  • Page Layout: It contains all the interfaces, server controls, text, inline JavaScript, and HTML tags.

The first step to implement programs in ASP.NET is to create a new project in Visual Studio. 

Visual Studio is an IDE (Integrated Development Environment) developed by Microsoft to create GUI applications. Form-based, as well as Web-based applications, can be designed through Visual Studio.

Let us see how to download and install Visual Studio.

Step 1: Microsoft Visual Studio can be downloaded from the URL https://www.visualstudio.com/downloads/.

ASP.NET First Program

Step 2: You can download any of the versions (Community, Professional, or Enterprise). Here we are installing the Community version. Click on Free download. A .exe file will begin to start. 

All IT Courses 50% Off
ASP.NET First Program

Step 3: Run the .exe file once the download completes. Click on Continue. Visual Studio will start downloading the files.

run-vs-exe-file

Step 4: Select the option ASP.NET and web development. .NET desktop application can also be selected if you want to develop desktop or console applications. We are selecting both the options right now and then click on Install.

selecting-options-in-visual-studio

Step 5: Visual Studio will start downloading the appropriate files based on the above selection.

installation-vs-2019

Step 6: Choose the development setting and color theme as per the choice. After selecting the required settings, click on Start Visual Studio.

Visual Studio Installation completes here.

 Now we are going to implement a simple basic program to print “Hello World.”

Step 1: Select File > New > Project.

vs2-11

Step 2: After we select the New Project, three different filters (Language, Platform, and Project Type) will appear on the page. We are not selecting any filter here. Simply click on ASP.NET Web Application (.NET Framework) and then Next.

selecting-asp-net-web-application

Step 3: Configure the project by entering the required fields such as Project Name, Solution Name, and click on Create button. The location of the project can also be modified.

project-configure-1

Step 4: Now, we have to choose the type of application. As we are creating a web application so we will choose Empty (to ensure that we are developing a simple application), check Web Forms (it will add all the basic folders), and click on Create button.

project-configure-3

Step 5: A solution explorer will open containing a file named as Global.asax.cs that contains all the application-specific variables.

ASP.Net - Intro, Life Cycle & Hello World Program

Step 6:  Now, we will need to add a web form to our project DemoApplication. For this right, click on DemoApplication > Add > Web Form.

ASP.Net - Intro, Life Cycle & Hello World Program

Step 7: Now, a prompt box will ask for the name of the web form. Enter the name and click on OK.

naming-web-form

Step 8: Now, we will write a simple code to print “Hello World.”

ASP.Net - Intro, Life Cycle & Hello World Program
<html xmlns="www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%Response. Write( "HeIIo World"); %>
</div>
</form>
</body>
</html>

Explanation of the code:

  • The Response object is used to revert the information back to the user.
  • Here we are using the method “write” to write the text “Hello World.”
  • The marker tags <% and %> are used to add a specific code.

When we run the above program in the Visual Studio, we will get the following output.

OUTPUT:

ASP.Net - Intro, Life Cycle & Hello World Program
Facebook Comments

Related Articles

Back to top button