First time at GK Digital?

GK Digital is an online, collaborative learning platform built from the ground up to be a superior learning experience on the web. It is self-paced and supported by instructors and peers. GK Digital is professional training in the 21st century, from Global Knowledge.
Activity: From static HTML to Razor dynamic content

The job of razor (or any view engine in MVC) is to take data which is usually generated by models, the controller, or some combination therein, and turn it into HTML.

A quick example. Suppose a view's purpose is to welcome the user to the site. Given a user object with a Name property, we might write code like this in the CSHTML file:

<h1>Welcome @Model.Name</h1>

This exercise takes you through many of the common code blocks you might need to write given mildly complex data in your view.

Note: If you are coming from ASP.NET WebForms, you've been told for many years that you MUST NOT write code in your ASPX files. Razor is quite different here. But there are equally strong guidelines. The solitary role of code in razor views is to turn data into HTML. That's it.

Repeat this to your self 5 times before you get started!

Role of code in razor views is to turn data into HTML. That's it.

OK, great. Keep that in mind and have a good time. Razor is fun stuff.

Preview any course on GK Digital for free.

Just choose a course from our catalog and then press preview course for free.