Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would recommend you using editor templates:</p> <pre><code>&lt;% using (Html.BeginForm()) { %&gt; &lt;%: Html.ValidationSummary(true) %&gt; &lt;fieldset&gt; &lt;legend&gt;Fixture&lt;/legend&gt; &lt;%: Html.HiddenFor(model =&gt; model.FixtureID) %&gt; &lt;%: Html.EditorForModel() %&gt; &lt;p&gt; &lt;input type="submit" value="Save" /&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;% } %&gt; </code></pre> <p>and inside <code>~/Views/Shared/EditorTemplates/Fixture.ascx</code>:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;RLSBCWebSite.Domain.Entities.Fixture&gt;" %&gt; &lt;%: Html.LabelFor(model =&gt; model.Gender) %&gt; &lt;%: Html.DropDownListFor( model =&gt; model.Gender, (ViewData["GenderList"] as SelectList) ) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.Gender) %&gt; &lt;%: Html.LabelFor(model =&gt; model.MatchType) %&gt; &lt;%: Html.DropDownListFor( model =&gt; model.MatchType, (ViewData["MatchTypeList"] as SelectList) )%&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.MatchType) %&gt; &lt;%: Html.LabelFor(model =&gt; model.TeamName) %&gt; &lt;%: Html.DropDownListFor( model =&gt; model.TeamName, (ViewData["TeamNameList"] as SelectList) )%&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.TeamName) %&gt; &lt;%: Html.LabelFor(model =&gt; model.MatchDate) %&gt; &lt;%: Html.TextBox( "MatchDate", Model.MatchDate.ToShortDateString() )%&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.MatchDate) %&gt; &lt;%: Html.LabelFor(model =&gt; model.Opponents) %&gt; &lt;%: Html.EditorFor(model =&gt; model.Opponents) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.Opponents) %&gt; &lt;%: Html.LabelFor(model =&gt; model.Venue) %&gt; &lt;%: Html.EditorFor(model =&gt; model.Venue) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.Venue) %&gt; &lt;%: Html.LabelFor(model =&gt; model.StartTime) %&gt; &lt;%: Html.EditorFor(model =&gt; model.StartTime) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.StartTime) %&gt; &lt;%: Html.LabelFor(model =&gt; model.ScoreFor) %&gt; &lt;%: Html.EditorFor(model =&gt; model.ScoreFor) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.ScoreFor) %&gt; &lt;%: Html.LabelFor(model =&gt; model.ScoreAgainst) %&gt; &lt;%: Html.EditorFor(model =&gt; model.ScoreAgainst) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.ScoreAgainst) %&gt; &lt;%: Html.LabelFor(model =&gt; model.Comments) %&gt; &lt;%: Html.DropDownListFor( model =&gt; model.Comments, (ViewData["CommentsList"] as SelectList) )%&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.Comments) %&gt; </code></pre> <p>A further improvement to this code would be to get rid of all <code>ViewData</code> and use strongly typed view models.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload