Web Pages. WebMatrix Microsoft WebMatrix is a free tool (stack) from Microsoft that developers can use to create, customize, and publish websites to the.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
The Web Warrior Guide to Web Design Technologies
Razor. Slide 2 Remember this? Browser Web Server HTTP Request HTTP Response (Web page / code) Client code (script) Interpret request Generate HTML and.
Virtual techdays INDIA │ 9-11 February 2011 Creating next generation websites Easier than ever, with WebMatrix Harish Ranganathan │ Developer Evangelist,
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Introduction to scripting
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Chapter 1: Introduction to Web
.Net is a collection of libraries, templates and services designed to make programming applications of all kinds, easier, more flexible (multi platform),
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
Chapter 16 The World Wide Web. 2 The Web An infrastructure of information combined and the network software used to access it Web page A document that.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
Advanced Web Forms with Databases Programming Right from the Start with Visual Basic.NET 1/e 13.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Session 10: Managing State. Overview State Management Types of State Management Server-Side State Management Client-Side State Management The Global.asax.
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
E-Commerce: Introduction to Web Development 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics What is a Web.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Python CGI programming
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Chapter 8 Cookies And Security JavaScript, Third Edition.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Tutorial 10 Programming with JavaScript
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
Cookies Web Browser and Server use HTTP protocol to communicate and HTTP is a stateless protocol. But for a commercial website it is required to maintain.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Session and Cookie Management in.Net Sandeep Kiran Shiva UIN:
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Chapter 4: Working with ASP.NET Server Controls OUTLINE  What ASP.NET Server Controls are  How the ASP.NET run time processes the server controls on.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● / www,histpk.org Hidaya Institute of Science & Technology
National College of Science & Information Technology.
4.01 How Web Pages Work.
Introduction to Dynamic Web Programming
ASP MVP Web applications and Razor
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
WEB PROGRAMMING JavaScript.
Intro to PHP.
PHP an introduction.
Presentation transcript:

Web Pages

WebMatrix Microsoft WebMatrix is a free tool (stack) from Microsoft that developers can use to create, customize, and publish websites to the Internet. WebMatrix supports many different options to build sites. It integrates a web server with database and programming frameworks to create a single, integrated experience.

WebMatrix WebMatrix can be used to code, test, and publish ASP.NET, PHP and other open source technology based website. WebMatrix can be used to start a new website using popular open-source apps like DotNetNuke, Umbraco, WordPress, or Joomla.

WebStack A web stack, in its simplest sense, is the collection of components that a website needs in order to run. These components include the operating system, the web server, the database, and the runtime and programming framework that underpins the web application.

WebMatrix

Web Pages (Razor C#) ASP.NET Web Pages with Razor Syntax is a web framework and part of WebMatrix. Razor is a simple to use, yet extremely powerful, programming syntax for inserting server-side code into web pages. An ASP.NET Web Page (.cshtml or.vbhtml) in WebMatrix, is a file that has two totally separate types of content: client-side server-side.

Web Pages (Razor C#) The client-side content of an ASP.NET Web Page can contain HTML, JavaScript, and CSS. The server-side content contains code to be executed by the web server in C# (or VB.NET), which is used to create dynamic content and interact with other resources, such as databases and file systems.

Web Pages

Web Page

Razor Engine

Forms

Razor C# A single line of server-side code can be added to an ASP.NET Web Page using symbol. The code is added in-line with the client-side content, such as HTML, and is recognised and processed automatically by the web server, substituting the Razor code with relevant dynamic content. The current date and time

Razor var PageTitle = "My Home The current date and time

Razor C# - // This is a comment. var myVar = 17; /* This is a multi-line comment that uses C# commenting syntax. A one-line code This is a multiline code comment. It can continue for any number of lines. }

Razor C# - white space Extra spaces in a statement (and outside of a string literal) don't affect the var lastName = "Smith"; } A line break in a statement has no effect on the statement, and you can wrap statements for readability. However, you can't wrap a line in the middle of a string literal. You can use the concatenation operator (+). You can also use character to create a verbatim string literal

Razor C# - code blocks The number 12 * 4 ) Code var movies = new List (); movies.Add(“Guns of Navarone"); movies.Add("The Godfather"); movies.Add("The Godfather: Part II"); movies.Add("The Good, the Bad and the Ugly"); movies.Add("Pulp Fiction"); }

(var movie in movies) }

Razor var telephoneNumber = " "; } Please var stevelydford = "me"; } Follow me on twitter:

Razor C# - text, code, markup If you are nesting a block of client-side content within a server-side code block, it is necessary to wrap the content within an HTML element such as,, or Use the special outputs a single line of content containing plain text or unmatched HTML tags.

Razor (loggedIn) { Welcome The time now Have a nice day! }

Razor C# - HTML encoding All content output to the browser, using Razor, is HTML encoded for security purposes. This means that reserved HTML characters are converted to their equivalent codes for display on the page : a < symbol is converted to &lt.

Razor var message = "You must be logged in to use this site.";

Razor C# The server will send the following encoded HTML to the browser You must be <a href='login.cshtml'>logged in</a> to use this site.

Razor C# To prevent this encoding, use the Html.Raw() var message = "You must be logged in to use this site.";

Razor C# - Layout Complete control on the look and feel of the Web Page. Web Pages in a website generally have common items such as headers, footers, navigation and common application specific content. A Layout template cab be defined. This facilitates consistency of design and user experience.

Razor C# - Layout Content shared across the web site is placed in a partial page. The content of the partial page can be imported into the content page (requested page) ”); Normally, such pages are kept in the shared folder.

Razor C# - Layout Partial Page Content Page

_Header.cshtml.: Bapatla Engineering College::Bapatla :.

_Footer.cshtml Copyright © 2011 Bapatla Engineering College | All Rights Reserved

var PageTitle = "Branches @PageTitle

Default.cshtml CSE IT ECE EIE EEE MECH CIVIL

OUTPUT

Razor C# - Layout template To create a common web page design throughout the website, Layout pages are used. Layout page contains the common content and design shared across all the pages. The Layout property of the content page is set to the path of the Layout page.

Razor C# - Layout template The content page when requested inherits the Layout page. When a request is made to the content page, the response serves the Layout page with the content page statement in the Layout page.

Razor C# - Layout template

Layout = "/Shared/_Layout.cshtml"; var PageTitle = "Branches Offered"; CSE IT ECE EIE EEE

OUTPUT

Razor C# At times, the content in the content page may be organized as different sections. A section is defined { } These sections can then be placed in the Layout page according to the required design ”). The content outside of any section is fetched

Razor C# - sections

Layout = "/Shared/_Layout.cshtml"; var PageTitle = "Branches Offered"; CSE IT ECE }

Default.cshtml Civil Mech Chemical

@RenderPage("/Shared/_Footer.cshtml")

Engineering College”; } Passing data to partial pages

@RenderPage("/Shared/_Footer.cshtml")

:.

Layout = "/Shared/_Layout.cshtml"; var PageTitle = "Branches Offered"; CSE IT ECE Civil Mech

Default.cshtml Civil Mech Chemical

Razor C# - Helpers Helpers are another way to achieve DRYness in your site design. A helper is a custom component that can receive a list of parameters in a way similar to a method call, and return HTML (or any kind of client- content) to be rendered on the page. Helpers and functions must be created within a folder in the root of the website called App_Code. This folder name is an ASP.NET convention that automatically makes all code within it available for use in the rest of your application.

Razor C# - Helpers The App_Code folder can contain sub-folders, the contents of which will also be accessible to the code in the rest of the site.

Razor C# - Helpers A call to this helper method can be made within any page by using symbol followed by the filename and helper name, separated by a “USB 8 GB", 5.00)

Razor C# - Functions Functions are static methods that can be called from anywhere in the WebMatrix application. Unlike helpers, which can return only a block of HTML for rendering in the browser, a function can return any valid C# type.

Razor C# - Functions

Razor C# - Session State HTTP is a stateless protocol. This means that a Web server treats each HTTP request for a page as an independent request. The server retains no knowledge of variable values that were used during previous requests. ASP.NET session state identifies requests from the same browser during a limited time window as a session, and provides a way to persist variable values for the duration of that session

Razor C# - Session State The ASP.NET session state facilitates to store and retrieve data per user, as they browse the web application. A session is started when the user first visits a page in the web site and ends either when the user closes the browser, or when the session “times out” due to inactivity after a predetermined period of time (set in IIS as twenty minutes, by default).

Razor C# - Session Variables Session variables are stored in a dictionary on the server, and are unique to each visitor per session. Session variables are exposed through the Session property of the WebPage object The Session variable collection is indexed by a string or an integer index. Session variables do not have to be explicitly added to the collection, they can simply be added or retrieved by referring to their name or index. By default, session variables can hold any valid.NET data type, including generic collections and custom objects.

Razor C# - Session Variables Session }else{ Visit Login Page }

Razor C# - Session if(IsPost){ Session["UserName"]=Request["uname"]; Response.Redirect("~/Default.cshtml"); } Login Page

Razor C# - Session Variables Welcome Bapatla Engineering College

Razor C# - Session Identifier All sessions created and maintained by the server are given a unique identifier, which is stored in the SessionID property of the page. Each new request for a page is examined to see if it already has a valid SessionID –if one is not present; the server starts a new session and assigns a new SessionID.

Razor C# - Cookies Cookies provide a means in Web applications to store user-specific information. For example, when a user visits your site, you can use cookies to store user preferences or other information. When the user visits your Web site another time, the application can retrieve the information it stored earlier. A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site.

Razor C# - Cookies For example, if a user requests a page from your site and your application sends not just a page, but also a cookie containing the date and time, when the user's browser gets the page, the browser also gets the cookie, which it stores in a folder on the user's hard disk. Later, if user requests a page from your site again, when the user enters the URL the browser looks on the local hard disk for a cookie associated with the URL. If the cookie exists, the browser sends the cookie to your site along with the page request. Your application can then determine the date and time that the user last visited the site.

Razor C# - Cookies Response.Cookies[“LastVisit"].Value = "patrick"; Response.Cookies[“LastVisit"].Expires = DateTime.Now.AddDays(1); HttpCookie aCookie = new HttpCookie(“LastVisit"); aCookie.Value = DateTime.Now.ToString(); aCookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(aCookie);

Razor C# - != null){ You visited this page at Request. Cookies[“LastVisit"].Value) }

Razor C# - var lv=""; if(Request.Cookies["LastVisit"]==null){ Response.Cookies["LastVisit"].Value= DateTime.Now.ToString(); }else{ lv=Request.Cookies["LastVisit"].Value; Response.Cookies["LastVisit"].Value=DateTime.Now.ToString(); } Response.Cookies["LastVisit"].Expires= DateTime.Now.AddDays(1); }

Razor C# - Cookies Welcome to Bapatla Engineering You Last Visited this page }