Lesson 1
Lesson 1
NET
1 Introduction to ASP.NET
By Hajrah Jahan
Mob: 055-1062252
What is .NET
● Cross-Platform Development
● Language Interoperability
● Unified Framework
Components of .Net Framework - What you can use?
compilation.
● The code that is directly managed by the CLR is called the managed code.
● When the managed code is compiled, the compiler converts the source code into
●
Components of .Net Framework - What you can use?
● Provides guidelines for declaring, using, and managing types at runtime, and
cross-language communication.
Components of .Net Framework - What you can use?
Metadata
● Metadata is the binary information describing the program, which is either stored
in a portable executable file (PE) or in the memory.
Assemblies
● A logical unit consisting of the assembly manifest, type metadata, IL code, and a
set of resources like image files.
Windows Forms
ASP.NET
ASP.NET AJAX
ADO.NET
● The technology used for working with databases providing access to data
sources like SQL server, OLE DB, XML etc for retrieving, manipulating, and
ASP.NET - Life Cycle - Application Life Cycle
● Helps in writing codes for making some specific thing happen at any stage of the
page life cycle.
● Also helps in writing custom controls & initializing them at right time, populate
their properties with view-state data and run control behavior code.
1. Initialization
5. Page rendering
ASP.NET page stages
1. Page request - When ASP.NET gets a page request, it decides whether to parse
and compile the page, or there would be a cached version of the page;
accordingly the response is sent.
2. Starting of page life cycle - At this stage, the Request and Response objects
are set. If the request is an old request or post back, the IsPostBack property of
the page is set to true. The UICulture property of the page is also set.
3. Page initialization - At this stage, the controls on the page are assigned
unique ID by setting the UniqueID property and the themes are applied. For a
new request, postback data is loaded and the control properties are restored to
the view-state values.
ASP.NET page stages
4. Page load - At this stage, control properties are set using the view state and
control state values.
5. Validation - Validate method of the validation control is called and on its
successful execution, the IsValid property of the page is set to true.
6. Postback event handling - If the request is a postback (old request), the
related event handler is invoked.
7. Page rendering - At this stage, view state for the page and all controls are
saved. The page calls the Render method for each control and the output of
rendering is written to the OutputStream class of the Response property of page.
8. Unload - The rendered page is sent to the client and page properties, such as
Response and Request, are unloaded and all cleanup done.
Examples of Companies Using .NET
Microsoft:
● Microsoft itself uses .NET for many of its applications, including parts of Windows
OS, Azure cloud services, and Microsoft Office Suite.
● Windows OS, Azure cloud services, Microsoft Office applications like Word and
Excel.
Stack Overflow:
● Stack Overflow, one of the largest online developer communities, uses ASP.NET
MVC and .NET technologies.
● Developers use Stack Overflow daily to ask and answer programming-related
Examples of Companies Using .NET
Intuit:
● Intuit, the company behind financial software like QuickBooks and TurboTax, uses
.NET technologies for their applications.
● QuickBooks and TurboTax are widely used financial management and tax
preparation software.
Jet.com:
GoDaddy:
How to go about?
● Microsoft provides a free version of visual studio which also contains SQL Server.
1. Page Directives:
a. Set up the environment for the page
to run.
b. Imports namespaces, loading
assemblies, and registering new
controls with custom tag names and
namespace prefixes.
2. Code Section:
a. Object model based code to control
events and other functions.
3. Page Layout:
a. Provides the UI of the page and
contains the HTML tags, server
controls, text, multimedia, inline CSS
Page Layout - HTML on the Server
TextBox Control:
Button Control:
Label Control:
ListView Control:
DropDownList Control:
CheckBox Control:
RadioButton Control:
Image Control
Calendar Control:
FileUpload Control
LinkButton Control:
ASP.NET Validators
Validation controls validate the user input data to ensure that useless, unauthenticated,
or contradictory data don't get stored.
Basic Properties
● ControlToValidate - Indicates the input control to validate.
● Display - Indicates how the error message is shown.
● EnableClientScript - Indicates whether client side validation will take place.
● Enabled - Enables or disables the validator.
● ErrorMessage - Indicates error string.
● Text - Error text to be shown if validation fails.
● IsValid - Indicates whether the value of the control is valid.
● SetFocusOnError - The focus should switch to the related invalid input control.
● ValidationGroup - The logical group of multiple validators, where this control
belongs.
●
ASP Controls
ASP.NET Validators
ASP.NET Validators
● RangeValidator - Verifies that the input value falls within a predetermined range.
ASP Controls
ASP.NET Validators
ASP.NET Validators
ASP.NET Validators
● RegularExpressionValidator
<asp:TextBox ID="EmailTextBox" runat="server"></asp:TextBox>
ControlToValidate="EmailTextBox"
ValidationExpression="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
Display="Dynamic"
ForeColor="Red" />
ASP.NET Validators
● URL:
Pattern: ^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$
Pattern: ^-?\d+(\.\d+)?$
Description: Validates both integer and decimal numbers, allowing negative values.
ASP Controls
ASP.NET Validators
Pattern: ^(0[1-9]|1[0-2])[-/](0[1-9]|[12]\d|3[01])[-/]\d{4}$
Pattern: ^[a-zA-Z0-9_]+$
ASP.NET Validators
Pattern: ^[a-zA-Z0-9_]+$
ASP.NET Validators
● Password (At least one uppercase letter, one lowercase letter, one digit, and minimum
length of 8 characters):
Pattern: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$
Description: Validates passwords containing at least one uppercase letter, one lowercase
letter, one digit, and a minimum length of 8 characters.
● IP Address (IPv4):
Pattern:^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\
d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$
ASP.NET Validators
ASP.NET Validators
● ValidationSummary - Does not perform any validation but shows a summary of all
errors in the page.
○ ShowSummary : shows the error messages in specified format.
○ ShowMessageBox : shows the error messages in a separate window.
ASP.NET - Classroom Activity 2
How to go about?
● Use your knowledge in controls and validations to develop a registration page for
making a graduation project request.
● Make sure you collect appropriate data related requesting approval of a
graduation project idea.