After studying this chapter you will be able to understand: Webpages introduction, webpages razor, webpages layout, webpages folders, webpages global, webpages forms, webpages objects, webpages files, webpages databases, webpages helpers, webpages webgrid, webpages charts, webpages email, webpages PHP, webpages publish.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad Virtual Campus, CIIT COMSATS Institute of Information Technology T2-Lecture-1 ASP.NET Part - I For Lecture Material/Slides Thanks to: www.w3schools.com Introduction Introduction ASP.NET is a development framework for building web pages and web sites with HTML, CSS, JavaScript and server scripting ASP.NET supports three different development models: ◦Web Pages, ◦Web Forms ◦MVC (Model View Controller), T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 1-4 Web Pages: Single Pages Model Simplest ASP.NET model Similar to PHP and classic ASP Built-in templates and helpers for database, video, graphics, social media and more T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 1-5 MVC: Model View Controller MVC separates web applications into different components: ◦Models for data ◦Views for display ◦Controllers for input T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 1-6 Web Forms: Event Driven Model The traditional ASP.NET event driven development model: Web pages with added server controls, server events, and server code T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 1-7 Classic ASP Classic ASP - Active Server Pages Active Server Pages (ASP), also known as Classic ASP, was introduced in 1998 as Microsoft's first server side scripting engine ASP is a technology that enables scripts in web pages to be executed by an Internet server ASP pages have the file extension asp, and are normally written in VBScript T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 1-8 ASP.NET ASP.NET is a new ASP generation It is not compatible with Classic ASP, but ASP.NET may include Classic ASP ASP.NET pages are compiled, which makes them faster than Classic ASP ASP.NET has better language support, a large set of user controls, XML-based components, and integrated user authentication ASP.NET pages have the extension aspx, and are normally written in VB (Visual Basic) or C# (C sharp) T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 1-9 ASP.NET User controls in ASP.NET can be written in different languages, including C++ and Java When a browser requests an ASP.NET file, the ASP.NET engine reads the file, compiles and executes the scripts in the file, and returns the result to the browser as plain HTML T2-Lecture-11 Ahmed Mumtaz Mustehsan www.w3schools.com 110 Output of above Example Example Code:- @foreach (var x in Request.ServerVariables) {
- @x }
Line @i
} } T2-Lecture-14 Ahmed Mumtaz Mustehsan www.w3schools.com 151 Arrays An array is useful when you want to store similar variables but don't want to create a separate variable for each of them: Example @{ string[] members = {"Jani", "Hege", "Kai", "Jim"}; int i = Array.IndexOf(members, "Kai")+1; int len = members.Length; string x = members[2-1]; } Members @foreach (var person in members) {@person
}The number of names in Members are @len
The person at position is @x
Kai is now in position @i
T2-Lecture-14 Ahmed Mumtaz Mustehsan Output Members Jani Hege Kai Jim The number of names in Members are The person at position is Hege Kai is now in position www.w3schools.com 152 Razor C# Logic ASP.NET Razor - C# Logic Conditions The If Condition C# lets you execute code based on conditions To test a condition you use an if statement The if statement returns true or false, based on your test: The if statement starts a code block The condition is written inside parenthesis The code inside the braces is executed if the test is true Example @{var price=50;} @if (price>30) {The price is too high.
} T2-Lecture-14 Ahmed Mumtaz Mustehsan www.w3schools.com 154 The Else Condition An if statement can include an else condition The else condition defines the code to be executed if the condition is false Example @{var price=20;} @if (price>30) {The price is too high.
} else {The price is OK.
} T2-Lecture-14 Ahmed Mumtaz Mustehsan www.w3schools.com 155 The Else If Condition Multiple conditions can be tested with an else if condition: Example @{var price=25;} @if (price>=30) {The price is high.
} else if (price>20 && price