mirror of
https://github.com/rudollee/LearningMVC.git
synced 2026-08-11 16:32:55 +00:00
Ch. 22 Templated Helper Methods
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
@model bool?
|
||||
|
||||
@if (ViewData.ModelMetadata.IsNullableValueType && Model == null)
|
||||
{
|
||||
@:(True) (False) <b>(Not Set)</b>
|
||||
}
|
||||
else if (Model.Value)
|
||||
{
|
||||
@:<b>(True)</b> (False) (Not Set)
|
||||
}
|
||||
else
|
||||
{
|
||||
@:(True) <b>(False)</b> (Not Set)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
@model Enum
|
||||
|
||||
@Html.DropDownListFor(m => m,
|
||||
Enum.GetValues(Model.GetType())
|
||||
.Cast<Enum>()
|
||||
.Select(m => {
|
||||
string enumVal = Enum.GetName(Model.GetTYpe()), m);
|
||||
return new SelectListItem()
|
||||
{
|
||||
Selected = (Model.ToString() == enumVal),
|
||||
Text = enumVal,
|
||||
Value = enumVal
|
||||
};
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
@model HelperMethods.Models.Role
|
||||
|
||||
@Html.DropDownListFor(m => m, new SelectList(Enum.GetNames(Model.GetType()), Model.ToString()))
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
<style type="text/css">
|
||||
label {display: inline-block; width: 100px;}
|
||||
div.dateElem {margin: 5px;}
|
||||
h2 > label { width: inherit;}
|
||||
.editor-label, .editor-field {float: left; margin-top: 10px;}
|
||||
.editor-field input { height: 20px; }
|
||||
.editor-label { clear: left;}
|
||||
.editor-field { margin-left: 10px; }
|
||||
input[type=submit] { float: left; clear: both; margin-top: 10px;}
|
||||
.column { float: left; margin: 10px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user