SlideShare a Scribd company logo
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Description
• To execute one or more C# statements, you can declare
a Razor code block by coding the @ sign followed by a
pair of curly braces ({ }). Within the curly braces, you
can code one or more C# statements.
• To evaluate a C# expression and display its result, you
can code an inline expression by coding the @ sign and
then coding the expression within a pair of parentheses.
For some expressions, the parentheses are optional.
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
A foreach loop that a list of links
The result displayed in a browser
Murach: ASP.NET Core MVC, How To Work With Razor Views
An if-else statement in a view
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
If necessary, the format specifiers round the number to the nearest decimal place. In most cases, that’s what you
want. If it isn’t, you can apply rounding before you display the view. For example, you can apply rounding in
the model. This figure presents three of the most common format specifiers, but many others exist. So, if you
need to apply formatting that goes beyond the formatting specified in this figure, you can search the Internet for
more information. In general, it’s considered a best practice for a controller or model to be responsible for
providing the data for a view. In other words, a view shouldn’t retrieve data from a database because that’s the
job of the controllers. Similarly, a view shouldn’t calculate a value to be displayed because that should be the job
of a model object. However, once the model object calculates the value, the view can format that value because
formatting and displaying data is the job of the view
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views

More Related Content

PDF
Murach: How to validate data in asp.net core mvc
PDF
Responsive Design and Bootstrap
PDF
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
PDF
Murach : How to work with session state and cookies
PDF
Murach : How to develop a single-page MVC web
PDF
Murach: How to use Entity Framework EF Core
PDF
Access tips access and sql part 6 dynamic reports
PDF
Diving into VS 2015 Day1
Murach: How to validate data in asp.net core mvc
Responsive Design and Bootstrap
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach : How to work with session state and cookies
Murach : How to develop a single-page MVC web
Murach: How to use Entity Framework EF Core
Access tips access and sql part 6 dynamic reports
Diving into VS 2015 Day1

What's hot (20)

PDF
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
PPTX
Visual Programming
PPTX
Gutmacher practical-coding-examples-for-sourcers-sc18 atl
PPS
Transforming Power Point Show with VBA
PPTX
DOCX
ASP.NET MVC3 RAD
PPTX
VBA
PPTX
Vba introduction
DOCX
Excel vba
DOCX
DOCX
Creating a data report in visual basic 6
PPT
A Lap Around Visual Studio 2010
PPT
E learning excel vba programming lesson 1
PPT
Visual Basic Programming
PDF
Oracle9i reports developer
PPTX
Salesforce connector Example
PDF
Handling errors in t sql code (1)
PDF
Access tips access and sql part 4 building select queries on-the-fly
PDF
Tutorial on how to load images in crystal reports dynamically using visual ba...
PDF
FlexNet Delivery and FlexNet Operations On-Demand Tips & Tricks
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
Visual Programming
Gutmacher practical-coding-examples-for-sourcers-sc18 atl
Transforming Power Point Show with VBA
ASP.NET MVC3 RAD
VBA
Vba introduction
Excel vba
Creating a data report in visual basic 6
A Lap Around Visual Studio 2010
E learning excel vba programming lesson 1
Visual Basic Programming
Oracle9i reports developer
Salesforce connector Example
Handling errors in t sql code (1)
Access tips access and sql part 4 building select queries on-the-fly
Tutorial on how to load images in crystal reports dynamically using visual ba...
FlexNet Delivery and FlexNet Operations On-Demand Tips & Tricks
Ad

Similar to Murach: ASP.NET Core MVC, How To Work With Razor Views (20)

PDF
Asp.Net MVC - Razor Syntax
PPS
Razor new view engine asp.net
PPTX
Intro to MVC 3 for Government Developers
PPTX
MVC & SQL_In_1_Hour
PPTX
Introduction towebmatrix
PPT
Super billing asp.net
PPTX
Intro to .NET for Government Developers
PDF
C 7 and NET Core Modern Cross Platform Development 2nd Edition Mark J. Price
PPTX
Programming languages asp.net
PDF
(Ebook) C# 6 and .NET Core 1.0: Modern Cross-Platform Development by Mark J. ...
PPTX
ASP.Net 5 and C# 6
PPTX
Mvc razor and working with data
PDF
ASP.NET MVC 3
PDF
ASP.NET Core Razor Pages in Action 1st Edition Mike Brind All Chapters Instan...
PPTX
Asp.net With mvc handson
PDF
ASP.NET Core Razor Pages in Action 1st Edition Mike Brind
PPTX
Asp.Net MVC 5 in Arabic
PPTX
Prairie Dev Con West - 2012-03-14 - Webmatrix, see what the matrix can do fo...
PPT
Lecture 1
PPSX
Session six ASP.net (MVC) View
Asp.Net MVC - Razor Syntax
Razor new view engine asp.net
Intro to MVC 3 for Government Developers
MVC & SQL_In_1_Hour
Introduction towebmatrix
Super billing asp.net
Intro to .NET for Government Developers
C 7 and NET Core Modern Cross Platform Development 2nd Edition Mark J. Price
Programming languages asp.net
(Ebook) C# 6 and .NET Core 1.0: Modern Cross-Platform Development by Mark J. ...
ASP.Net 5 and C# 6
Mvc razor and working with data
ASP.NET MVC 3
ASP.NET Core Razor Pages in Action 1st Edition Mike Brind All Chapters Instan...
Asp.net With mvc handson
ASP.NET Core Razor Pages in Action 1st Edition Mike Brind
Asp.Net MVC 5 in Arabic
Prairie Dev Con West - 2012-03-14 - Webmatrix, see what the matrix can do fo...
Lecture 1
Session six ASP.net (MVC) View
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Basic Mud Logging Guide for educational purpose
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
01-Introduction-to-Information-Management.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Types and Its function , kingdom of life
O7-L3 Supply Chain Operations - ICLT Program
Basic Mud Logging Guide for educational purpose
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
VCE English Exam - Section C Student Revision Booklet
01-Introduction-to-Information-Management.pdf
TR - Agricultural Crops Production NC III.pdf
human mycosis Human fungal infections are called human mycosis..pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Pharma ospi slides which help in ospi learning
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
Classroom Observation Tools for Teachers
master seminar digital applications in india
Institutional Correction lecture only . . .
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra

Murach: ASP.NET Core MVC, How To Work With Razor Views

  • 5. Description • To execute one or more C# statements, you can declare a Razor code block by coding the @ sign followed by a pair of curly braces ({ }). Within the curly braces, you can code one or more C# statements. • To evaluate a C# expression and display its result, you can code an inline expression by coding the @ sign and then coding the expression within a pair of parentheses. For some expressions, the parentheses are optional.
  • 8. A foreach loop that a list of links The result displayed in a browser
  • 10. An if-else statement in a view
  • 47. If necessary, the format specifiers round the number to the nearest decimal place. In most cases, that’s what you want. If it isn’t, you can apply rounding before you display the view. For example, you can apply rounding in the model. This figure presents three of the most common format specifiers, but many others exist. So, if you need to apply formatting that goes beyond the formatting specified in this figure, you can search the Internet for more information. In general, it’s considered a best practice for a controller or model to be responsible for providing the data for a view. In other words, a view shouldn’t retrieve data from a database because that’s the job of the controllers. Similarly, a view shouldn’t calculate a value to be displayed because that should be the job of a model object. However, once the model object calculates the value, the view can format that value because formatting and displaying data is the job of the view