|
Microsfot .NET Overview |
What is Microsoft .NET?
|
Microsoft .NET is a software development environment that can be used to develop different types of applications.The following are the different types of applications that we can develop with .NET:
- Web Applications
- Web Servies
- Windows Applications
- Windows Services
- Console Applications
- Mobile Applications
This tutorial will help you learn how to develop Web Applications and Web Services.
|
|
A simple "HELLO" Web Application
|
Open visual studio -> Click File -> Point on New -> Click Web Site
Now you will see a "New Web Site" dialog box as shown in Figure 1 below
|

Figure 1 |
From the "Visual Studio installed templates" sections select ASP.NET Web Site. From the "Location" dropdownlist choose "File System". Next to the location dropdownlist choose the location where you want to create the website, For this example lets use "C:\Hello".Select "Language" as "Visual C#" and click OK button.
Visual Studio will now create a web application with the name as "Hello" and this project is saved in C:\Hello folder.
Let us now create user interface on the default.aspx page that is generated by visual studio.
If you look at the bottom of Default.aspx page you will see 2 tabs:
- Design : The design tab will show you the graphical interface.
- Source : The Source Tab will contain our default.aspx HTML Code.
Click on the "Design" Tab. From the tool box on the left hand side drag and drop a Label Control from the Standard section.Right Click the Label Control and select properties.
In the Properties window set the "Text" property of the Label to "Please Enter Your Name".
Now drag and drop a "TextBox","Button" and a Label control from the tool box onto the webform and have the design of the Page as shown in Figure 2 below.
|

Figure 2 |
|
We are done designing our web page. To run the page click "Debug" from the menu.
Click on "start without debugging".The application runs and our webpage is displayed
in the browser window. Web pages in ASP.NET are called as WebForms. Type your name
in the "TextBox" and Click the Button. Nothing happens as we have not written any
code. Before we write any code lets understand the key points |
Take Awaya Key Points:
- Web Pages in ASP.NET are called Webforms and they will have .aspx
extension
- Webforms have two modes : Source and Design
- In Source Mode of the Webform we have the webform HTML code
- In the Design Mode, we can graphically design the webform
|
When we clicked on the button nothing happened. Now let us write some server side
code. Double click on the button on webform in Visual Studio. Default.aspx.cs will
open up. This is the page where we write server side code. In default.aspx.cs write
the code as shown in the below code snippet. In Button1_Click() function we are
setting the Text property of Label2 to "Hello " + TextBox1.Text. What this will
do is when we click the button after running the application, whatever text we have
in TextBox1 is taken out and appended to "Hello" string and the resulting string
is set as Text property to the Label2 control.
In this application default.aspx.cs is called as CodeBehind file. |
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text = "Hello " + TextBox1.Text;
}
} |
The code that we have written in default.aspx.cs is called server side code and will be executed on the webserver. The programming language we have used in this example is Visual C#. Visual studio supports any of the following 3 programming languages. Any type of .NET application that we develop can use any language.
- Visual Basic
- Visual C#
- Visual J#
|
Take Awaya Key Points:
- Every webform will have a codebehind file associated, and will have the following extension depending on the prgramming language chosen
- .aspx.cs (If Visual C# is the programming language)
- .aspx.vb (If Visual basic is the programming language)
- .aspx.js (If Visual J# is the programming language)
- CodeBehind file will contain the server side code that will be executed on the webserver.
|
In this article we have seen how to develop a simple web application. In our next
article we will see how and what happens when a .NET application is executed.
|
Njoy Programming
ByPrasad Cherukuri
|