Académique Documents
Professionnel Documents
Culture Documents
Master subtitle
style
05 | Customizing Views
Jon Galloway | Development Platform Evangelist
Christopher Harrison | Content Development
Manager
Click to edit
Master subtitle
style
Finding Views
It just works Jon Galloway
Views reside in the Views folder
Subfolders
Name of the controller
Shared
DEMO
View Resolution
Click to edit
Master subtitle
style
Click to edit
Master subtitle
style
Razor Syntax
Razor Syntax
@ indicates server-side code
MVC runtime determines meaning of @ based on
context
<a href="mailto:me@demo.com">
Use @@ for @
DEMO
Razor Syntax
Click to edit
Master subtitle
style
HtmlHelper
HtmlHelper
Helps generate HTML
Uses attributes on model
Display names
Formatting
Input elements
Name
Displaying Data
DisplayNameFor
DisplayName attribute
Display attribute, Name property
DisplayFor
Uses DisplayFormat (if applicable)
DEMO
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
Creates a label element
Useful for touch
InputFor
Creates input element
Uses HTML5 based on DataType attribute
DEMO
Basic Forms
Validation
ValidationMessageFor
Display error message next to text box
ValidationSummary
Display all error messages in one location
DEMO
Adding Validation
Click to edit
Master subtitle
style
Layouts
My Music Store
New This Week!
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.
Scripts
Banners
Sidebars
Use @section name
Note the casing
DEMO
Using Layouts
2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered
trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of
Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a
commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT
MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.