05 | Customizing Views Jon Galloway | Development Platform Evangelist

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

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?
Sharpen Your MVC Views with Razor By Jon Marozick.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Tutorial 6 Creating a Web Form
Introduction to MVC Action Methods, Edit View, and a Search Feature NTPCUG Dr. Tom Perkins.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Tutorial 6 Working with Web Forms
Personal Independent Networking Project HTML Forms by Chris Smith.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
What’s new in ASP.NET MVC 3 Building a NerdDinner/AppStore Application.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
INTERNET APPLICATION DEVELOPMENT For More visit:
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
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.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Server-side Scripting Powering the webs favourite services.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
IT Introduction to Website Development Welcome!
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 4-1 of…
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to ASP.NET T.Ahlam Algharasi. The Visual Studio IDE Start page 2.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
ASP.NET MVC Architecture Layouts, Filters, Sections, Helpers, Partial Views, Areas… SoftUni Team Technical Trainers Software University
CSE 409 – Advanced Internet Technology Today you will learn  Styles  Themes  Master Pages Themes and Master Pages.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Tutorial 6 Creating a Web Form
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Tutorial 6 Working with Web Forms
Getting Started with Dreamweaver
Chapter 5 Validating Form Data with JavaScript
Getting Started with MVC 5 and Visual Studio 2013
Running a Forms Developer Application
Getting Started with CSS
Chapter 2: The Visual Studio .NET Development Environment
In this session, you will learn to:
Social Media And Global Computing Introduction to The MVC Pattern
ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction
ASP MVP Web applications and Razor
MIS Professor Sandvig MIS 324 Professor Sandvig
Data Virtualization Tutorial… CORS and CIS
Objectives Design a form Create a form Create text fields
Play Framework: Introduction
ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction
Social Media And Global Computing Managing MVC with Model Validation
04 | Customizing Controllers
Designing Forms Lesson 10.
Unit 27 - Web Server Scripting
Layout and Partial Views
Social Media And Global Computing Managing MVC with Model Validation
Controllers.
WEB PROGRAMMING JavaScript.
Working with Server-side Scripts
Starting to develop a website
Customizing Views Views Customize කර ගැනීම
CNIT 131 HTML5 - Forms.
Working with Text and Cascading Style Sheets
Getting Started with Dreamweaver
Functions Christopher Harrison | Content Developer
Web Development Using ASP .NET
Layout and Partial Views
Presentation transcript:

05 | Customizing Views Jon Galloway | Development Platform Evangelist Christopher Harrison | Content Development Manager

Changing the Outlook on Views How Views are Found Views and Models Razor Syntax HtmlHelper Layouts

How Views are Found

Finding Views “It just works” – Jon Galloway Views reside in the Views folder Subfolders Name of the controller Shared

View Resolution in Action public class AlbumController : Controller { public ActionResult Index() { return View(); } } Look for a view named Index in a folder named Album Look for a view named Index in a folder named Shared Error

View Resolution in Action Again public class AlbumController : Controller { public ActionResult Index() { return View("Default"); } } Look for a view named Default in a folder named Album Look for a view named Default in a folder named Shared Error

View Resolution

Views and Models

Views and Models Views have a Model property Type is set by @model declaration Note the CaSiNg Advanced note Views do not need to have a typed model Useful for creating dynamic views

Razor Syntax

Razor Syntax @ indicates server-side code MVC runtime determines meaning of @ based on context <a href="mailto:me@demo.com"> generates appropriate HTML Use @@ for @

Razor Syntax

HtmlHelper

HtmlHelper Helps generate HTML Uses attributes on model Display names Formatting Input elements

HtmlHelper and Lambdas @Html.DisplayFor(model => model.Name) MVC uses reflection Reflection isn’t evil! Helper methods need the property, not the value @Html.DisplayFor(Model.Name) would pass the value of Name Consider @Html.DisplayFor(m => m.Name) for easier reading

Displaying Data DisplayNameFor DisplayFor DisplayName attribute Display attribute, Name property DisplayFor Uses DisplayFormat (if applicable)

Displaying Data

Creating Forms HtmlHelper.BeginForm() Why not just use a form element? URLs can always change Parameters Action name Controller name Form method Get Post

Accepting Input LabelFor InputFor Creates a label element Useful for touch InputFor Creates input element Uses HTML5 based on DataType attribute

Basic Forms

Validation ValidationMessageFor ValidationSummary Display error message next to text box ValidationSummary Display all error messages in one location

Adding Validation

Layouts

Welcome! My Music Store New This Week! Popular Items FAQs Deleted Smiths Singles Original - not rereleased - Frank Zappa Albums Welcome! Feel free to look around. All records are available for sale. Popular Items The Three EPs The Beta Band I Just Called to Say I Love You Stevie Wonder FAQs Q: Do you have soul? A: That all depends.

Organization and Consistency Use layouts to ensure consistent page structure Layout methods RenderBody() Renders anything in a view not in a section RenderSection(name, required) Allow views to add specific sections Scripts Banners Sidebars Use @section name to create section in view Note the casing

Using Layouts