ASP MVP Web applications and Razor

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Sharpen Your MVC Views with Razor By Jon Marozick.
Java Script Session1 INTRODUCTION.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Web Warrior Guide to Web Design Technologies
Languages for Dynamic Web Documents
Razor. Slide 2 Remember this? Browser Web Server HTTP Request HTTP Response (Web page / code) Client code (script) Interpret request Generate HTML and.
Multiple Tiers in Action
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Introduction to scripting
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Web Pages. WebMatrix Microsoft WebMatrix is a free tool (stack) from Microsoft that developers can use to create, customize, and publish websites to the.
4.1 JavaScript Introduction
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.
JavaScript Syntax, how to use it in a HTML document
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Scripting Languages Client Side and Server Side. Examples of client side/server side Examples of client-side side include: JavaScript Jquery (uses a JavaScript.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Introduction  “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Jim Fawcett CSE686 – Internet Programming Spring 2014
Objective % Select and utilize tools to design and develop websites.
Introduction to Dynamic Web Programming
Jim Fawcett CSE686 – Internet Programming Spring 2012
Chapter 8 User Controls.
Section 17.1 Section 17.2 Add an audio file using HTML
JavaScript Syntax and Semantics
Haritha Dasari Josue Balandrano Coronel -
Objective % Select and utilize tools to design and develop websites.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
PHP / MySQL Introduction
PHP Introduction.
Introduction to JavaScript
JavaScript Introduction
A second look at JavaScript
Web Development Using ASP .NET
Anatomy of an ASP.NET Page
PHP.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Introduction to JavaScript
Tutorial 10: Programming with javascript
An Introduction to JavaScript
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
PHP an introduction.
Client-Server Model: Requesting a Web Page
Presentation transcript:

ASP MVP Web applications and Razor

HTTP Response (Web page / code) Remember this? Browser Web Server HTTP Request Interpret request Client code (script) Generate HTML and script HTTP Response (Web page / code)

A Revised Model Browser Web Server (IIS) HTTP Request .NET Programming Models (Handlers) Web Forms MVC Web Pages (Razor) Client code (script) HTTP Response (Web page / code)

The .NET Models (Pillars) Web Forms (These are the traditional ASP.NET applications we have been creating) Web Pages (Razor) Looks much like PHP Model View Controller (MVC) A framework-based environment It uses Razor as the rendering engine Same MVC discussed last time

Comparing MVC / Razor and Traditional Web Forms Traditional Web forms are rich with 100s of server-side events Without these, MVC applications are more work to develop Razor and MVC are lightweight MVC does not use view state or session state It’s up to you to handle this task It’s designed to be RESTful

The Razor Model Razor ASP .NET Framework

MVC Razor Project Structure MVC and Razor projects are expected to have a well-defined structure Adhere to it

MVC Razor Page References (1) Use relative references To specify the virtual root in programming code, use the ~ operator (same as what you are used to) Use Server.MapPath to make absolute references

Razor Application Flow _AppStart runs first and executes startup code The underscore character keeps files from being browsed directly Only runs on the first site request _PageStart runs before every page in a particular folder (again this environment is folder-based)

Razor Application Flow

Razor (Introduction) It’s the newer view engine for ASP It’s code looks much like PHP Code is embedded into an HTML document These are .cshtml files in Razor It relies on the .NET framework, as you would expect It works with databases We still have web.config

Razor (Introduction) ASP.NET control’s don’t work. So you can only use the intrinsic HTML controls Razor is HTML 5 compliant You can also use jQuery and JavaScript It has both C# and VB versions C# is case sensitive as always There is no code-behind file

Razor (Characteristics) The <% %> syntax is replaced with a leading @ Code blocks appear in @{} blocks in C# VB has a similar construct There are a bunch of new objects

Creating a Razor Project It’s a project with a template like anything else Just create a new Web project

Types of Razor Code Blocks Inline The @ character calls a function or evaluates a character within some HTML code It says the code is Razor code, rather than HTML Single Statement Statement appears in the @{} block as in @{ var x = 10;} Multi Statement Use the single statement syntax with multiple statements (separated by a semi-colon);

Inline (Example) Code appears embedded inside some HTML Call the Today method Note that the .NET classes are the same as always @System.DateTime.Today.ToString()

Single Statement Example As the name implies, it’s a single statement that appears in a @{} block @{ var x = 10;}

Multi-statement Example Multiple statements appear in a @{} block A semi-colon separates each statement @{ Layout = "~/_SiteLayout.cshtml"; Page.Title = "Welcome to my Site!"; }

Layouts (Introduction) We have been using Master pages to give consistent look-and-feel to pages Layouts are the Razor method of doing this Create a layout page From the other pages, we reference the Layout page with the @Layout method

Layouts (Implementing) The layout page is the outer HTML document It contains the <html> tags Within the content, Call @RenderSection to render a xxx tag. Call @RenderBody to insert the content where the RenderBody is called The content page must start with a @Layout directive

Layouts (Content Page) Reference the layout page @section name mark the sections

Layouts (Master Page) Here we call @RenderSection and @RenderBody to render the parts of the content page

Other Page Methods Method Description href Builds a URL using the specified parameters RenderBody() Renders the portion of a content page that is not within a named section (In layout pages) RenderPage(page) Renders the content of one page within another page RenderSection(section) Renders the content of a named section (In layout pages) Write(object) Writes the object as an HTML-encoded string WriteLiteral Writes an object without HTML-encoding it first

Other Page Properties Property Description isPost Returns true if the HTTP data transfer method used by the client is a POST request Layout Gets or sets the path of a layout page Page Provides property-like access to data shared between pages and layout pages Request Gets the HttpRequest object for the current HTTP request Server Gets the HttpServerUtility object that provides web-page processing methods

Razor Syntax (2) There are many redefined objects Request, Response… just as in asp.net

Razor Syntax (3) Decision making and loops are supported

User Input (Forms) Unlike Traditional Web forms, we use traditional HTML input controls We reference those through the Request object Example (Get the contents if the input control named text1 var num1 = Request["text1"];  http://www.w3schools.com/aspnet/webpages_forms.asp

Helpers Helpers are conceptually similar to ASP.NET controls. They simplify the process of doing something http://www.w3schools.com/aspnet/webpages_helpers.asp

The ViewBag The model is used to send data to a Razor view Temporary data (not included in the model) can also be transferred from the controller to the view Data is not transferred from the view to the controller

Other Razor Capabilities We can work with text files We can work with database

Type Conversion Like PHP and JavaScript, Razor is loosely typed Call the “As” functions to convert types AsInt, AsFloat, Asxxx…