2. What is ASP.Net?
• ASP.Net is a web development platform provided by
Microsoft. It is used for creating web-based
applications. ASP.Net was first released in the year
2002.
• The first version of ASP.Net deployed was 1.0. The most
recent version of ASP.Net is version 4.6. ASP.Net is
designed to work with the HTTP protocol. This is the
standard protocol used across all web applications.
• ASP.Net applications can also be written in a variety of
.Net languages. These include C#, VB.Net.
3. ASP.NET Architecture and its
Components
• ASP.Net is a framework which is used to develop
a Web-based application. The basic architecture
of the ASP.Net framework is as shown below.
4. ASP.NET Architecture Contd..
The architecture of the .Net framework is based on the
following key components
• Language – A variety of languages exists for .NET framework.
They are VB.net and C#. These can be used to develop web
applications.
• Library - The .NET Framework includes a set of standard class
libraries. The most common library used for web applications
in .net is the Web library. The web library has all the necessary
components used to develop .Net web-based applications.
• Common Language Runtime - The Common Language
Infrastructure or CLI is a platform. .Net programs are executed
on this platform. The CLR is used for performing key activities.
Activities include Exception handling and Garbage collection.
5. Below are some of the key
characteristics of the ASP.Net
framework
• Code Behind Mode
– This is the concept of separation of design and code
– web page called MyPage.aspx. There will be another
file called MyPage.aspx.cs which would denote the
code part of the page
• State Management
• Caching
• ASP.NET and ASP.NET AJAX
• ADO.NET
• Windows Forms
6. What is ASP.Net Lifecycle?
• When an ASP.Net application is launched,
there are series of steps which are carried
out.
7. What is ASP.Net Page Lifecycle?
• When an ASP.Net page is called, it goes through a
particular lifecycle. This is done before the
response is sent to the user.
8. ASP.NET - Environment Setup
Step 1) The first step involves the creation of a new project in
Visual Studio. After launching Visual Studio, you need to
choose the menu option New->Project.
9. Contd...
Step 2) The next step is to choose the project type as an ASP.Net
Web application. Here we also need to mention the name and
location of our project.
10. Contd...
Step 3) In the next screen, you have to choose the type of
ASP.net web application that needs to be created. In our case,
we are going to create a simple Web Form application.
11. Contd...
• If the above steps are followed, you will get
the below output in Visual Studio.
Output:-
12. Contd...
• Step 4) Now, it's time to add a Web Form file to
the project. This is the file which will contain all
the web-specific code for our project.
13. Contd...
• Step 5) In the next
screen we are going to
be prompted to provide
a name for the web
form.
• Give a name for the
Web Form. In our case,
we are giving it a name
of Demo.
• Click the Ok button.
14. Contd...
• Step 6) The next step is to add the code, which
will do the work of displaying "Hello World." This
can be done by just adding one line of code to
the Demo.aspx file.
17. ASP.NET - Event Handling
• An event is an action or occurrence such as a
mouse click, a key press, mouse movements,
or any system-generated notification.
Event Arguments
The general syntax of an event is:
private void EventName (object sender,
EventArgs e){}
18. Event Handling Using Controls
The ASP tag for a button control:
<asp:Button ID="btnCancel" runat="server"
Text="Cancel" />
<asp:Button ID="btnCancel" runat="server"
Text="Cancel" Onclick="btnCancel_Click" />
19. ASP.NET Controls:
• ASP.Net has the ability to add controls to a
form such as textboxes and labels.
Step 1) The first step is to open the Forms
Designer for the Demo web form. Once you
do this, you will be able to drag controls from
the toolbox to the Web form.
– To open the Designer web form,
– Right-click the Demo.aspx file in the Solution
Explorer and
– Choose the menu option View Designer.
21. Contd...
• Once you perform the above step, you will be
able to see your Form Designer as shown
below.
22. Contd...
• Label Control
– The label control is used to display a text or a
message to the user on the form. The label control
is normally used along with other controls.
23. Contd...
Step 2) Once the label has been added, follow
the following steps.
– Go to the properties window by right-clicking on
the label control
– Choose the Properties menu option
24. Contd...
Step 3) From the
properties
window,
change the
name of the
Text property
to Name
25. Contd...
• Similarly, also change
the ID property value
of the control to
lblName. By
specifying a
meaningful ID to
controls, it becomes
easier to access them
during the coding
phase. This is shown
below.
26. Contd...
• Once you make
the above
changes, you will
see the following
output
Output:-
27. sum of 2 asp:textbox values using c#
asp.net
First Number: <asp:TextBox runat="server"
id="TB1" /><br />
Second Number: <asp:TextBox runat="server"
id="TB2" /><br />
<asp:Button runat="server" id="CalculateBtn"
OnClick="CalculateBtn_Click" Text="Calcualte
Sum" />
Sum: <asp:TextBox runat="server" id="SumTB" />
28. Contd...
protected void CalculateBtn_Click (object
sender, EventArgs e)
{
int num1 = Int32.Parse(TB1.Text);
int num2 = Int32.Parse(TB2.Text);
int sum = num1+num2;
SumTB.Text = sum.ToString();
}
29. Example
simple example has a text box control where
the user can enter name, a button to send
the information to the server, and a label
control to display the URL of the client
computer.