ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction

Slides:



Advertisements
Similar presentations
AngularJS Routing Routes, Route Parameters, Templates, Location, Navigation SoftUni Team Technical Trainers Software University
Advertisements

Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University
ASP.NET MVC Architecture Layouts, Filters, Sections, Helpers, Partial Views, Areas… SoftUni Team Technical Trainers Software University
Jekyll Static Site Generator Template-Based Site Generation Svetlin Nakov Technical Trainer Software University
Working with Data Model Binders, Display Templates, Editor Templates, Validation… SoftUni Team Technical Trainers Software University
Sets, Dictionaries SoftUni Team Technical Trainers Software University
Doctrine The PHP ORM SoftUni Team Technical Trainers Software University
Stacks and Queues Processing Sequences of Elements SoftUni Team Technical Trainers Software University
Version Control Systems
Auto Mapping Objects SoftUni Team Database Applications
Static Members and Namespaces
Databases basics Course Introduction SoftUni Team Databases basics
Interface Segregation / Dependency Inversion
C# MVC Frameworks – ASP.NET
ASP.NET Essentials SoftUni Team ASP.NET MVC Introduction
Web API - Introduction AJAX, Spring Data REST SoftUni Team Web API
Introduction to MVC SoftUni Team Introduction to MVC
Deploying Web Application
PHP MVC Frameworks Course Introduction SoftUni Team Technical Trainers
Reflection SoftUni Team Technical Trainers Java OOP Advanced
ASP.NET Integration Testing
ASP.NET Unit Testing Unit Testing Web API SoftUni Team ASP.NET
Classes, Properties, Constructors, Objects, Namespaces
Mocking tools for easier unit testing
JavaScript Applications
State Management Cookies, Sessions SoftUni Team State Management
PHP MVC Frameworks MVC Fundamentals SoftUni Team Technical Trainers
Software Technologies
EF Relations Object Composition
Entity Framework: Code First
Repeating Code Multiple Times
Databases advanced Course Introduction SoftUni Team Databases advanced
C#/Java Web Development Basics
MVC Architecture. Routing
Install and configure theme
Balancing Binary Search Trees, Rotations
Entity Framework: Relations
Caching Data in ASP.NET MVC
Functional Programming
The Right Way Control Flow
MVC Architecture, Symfony Framework for PHP Web Apps
Transactions in Entity Framework
ASP.NET MVC Introduction
C# Advanced Course Introduction SoftUni Team C# Technical Trainers
Databases Advanced Course Introduction SoftUni Team Databases Advanced
C# Web Development Basics
Best practices and architecture
Arrays and Multidimensional Arrays
Design & Module Development
Magento Basics part 2 Modules & Themes Stenik Group Ltd. Magento
Multidimensional Arrays, Sets, Dictionaries
Extending functionality using Collections
ASP.NET REST Services SoftUni Team ASP.NET REST Services
ASP.NET Filters SoftUni Team ASP.NET MVC Introduction
Making big SPA applications
Functional Programming
ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction
C# Advanced Course Introduction SoftUni Team C# Technical Trainers
Course Overview, Trainers, Evaluation
Exporting and Importing Data
Introduction to TypeScript & Angular
CSS Transitions and Animations
Train the Trainers Course
Iterators and Comparators
Spring Data Advanced Querying
Version Control Systems
JavaScript Frameworks & AngularJS
/^Hel{2}o\s*World\n$/
JavaScript: ExpressJS Overview
CSS Transitions and Animations
Presentation transcript:

ASP.NET Razor Engine SoftUni Team ASP.NET MVC Introduction Technical Trainers Software University http://softuni.bg

Have a Question? sli.do #CSharpWeb

Table of Contents Layouts Partial Views Html helper templates Toolbox for HTML and Bootstrap

Layout Defines a common site template Razor view engine renders content inside-out First the view is redered, then the layout @RenderBody() Indicates where the view content should be placed when rendering

Views and Layouts Views don't need to specify layout since their default layout is set in their _ViewStart file: ~/Views/_ViewStart.cshtml (code for all views) Each view can specify custom layout pages Views without layout: @{ Layout = "~/Views/Shared/_UncommonLayout.cshtml"; } @{ Layout = null; }

Sections You can have one or more "sections" (optional) They are defined in the views: And may be rendered anywhere in the layout page using the method RenderSection() @RenderSection(string name, bool required) If the section is required and not defined, an exception will be thrown (IsSectionDefined())

Partial Views Partial views render portions of a page Reuse pieces of a view Html helpers – Partial(), and Action() Razor partial views are still .cshtml files To annotate that an action from the controller should not be called outside of the application put [ChildActionOnly]

Display & Editor Templates * Display & Editor Templates (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Templates ASP.NET MVC comes with helper methods DisplayFor(), DisplayForModel() EditorFor(), EditorForModel() There are default implementations Can be configured easily Create folders "DisplayTemplates" and "EditorTemplates" in the “Views/Shared" folder or in the "Views/{Controller}" folder

Custom Templates In the two new folders create a view for each type you want The file name must be the same as the type name string -> String.cshtml int -> Int32.cshtml DateTime -> DateTime.cshtml Student -> Student.cshtml The name of the files must reflect the data types and the @model in them

Custom Templates The display / editor templates are normal view files The framework will start using them instead of the default implementations Example – String.cshtml All strings will be in paragraph element and will have quotes surrounding them DisplayFor(), EditorFor() - for properties in the model DisplayForModel(), EditorForModel() – for the entire model

Custom Template Name Sometimes you need two templates for one data type Create the template with custom name Decorate the property in the model with the [UIHint] attribute specifying the template name You can set the name in the helpers too

Toolbox for HTML and Bootstrap Open View -> Toolbox from the menu bar.

ASP.NET Razor Engine https://softuni.bg/courses/ © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license.

License This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license.

Free Trainings @ Software University Software University Foundation – softuni.org Software University – High-Quality Education, Profession and Job for Software Developers softuni.bg Software University @ Facebook facebook.com/SoftwareUniversity Software University @ YouTube youtube.com/SoftwareUniversity Software University Forums – forum.softuni.bg © Software University Foundation – http://softuni.org This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license.