@using MvcSample.Web.Models
@using Microsoft.AspNet.Mvc.ModelBinding
@model User
@{
ViewBag.Title = (Model == null) ? "Create Page" : "Edit Page";
if (ViewBag.Gift == null)
{
ViewBag.Gift = "nothing";
}
}
@ViewBag.Title
Thanks for @ViewBag.Gift
@if (Model == null)
{
Howdy, your model is null.
}
else
{
Hello @Model.Name! Happy @(Model.Age)th birthday.
}
@{
var metadata = ViewData.ModelMetadata;
if (metadata != null)
{
var typeName = metadata.ModelType.Name;
var description = metadata.Description;
@typeName has description '@description' and contains
@foreach (var property in metadata.Properties)
{
@PropertyListItem(property)
}
}
}
@helper PropertyListItem(ModelMetadata property)
{
var propertyName = property.PropertyName;
var propertyTypeName = property.ModelType.Name;
Property @propertyName is type @propertyTypeName and '@(property.Description ?? "no description")'
}