Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><sup>I know this isn't strictly an answer to your question, but since I still want to suggest a plan of action, I'll post it like this rather than in a comment.</sup></p> <hr> <p><strong>Are you sure you want this?</strong> </p> <p>If you manage to do this, you will set the <em>label</em> of a field to some value based on its <em>type</em>. This might seem tempting at first glance - you could possibly save yourself some key strokes every here and there.</p> <p>But what happens if you e.g. have a type <code>Address</code> containing some properties for street name, number, zip code etc, and then want the user to fill in the home address and the work address in the same form - how would you label them differently and still use the same type? And even worse - do you <em>really</em> want the same label on all your strings? In order to avoid these two scenarios, you'll need to resort to <code>Html.DisplayFor(m =&gt; m.PropertyName, "TemplateName")</code> anyway, which means you'll be in just as sorry a situation as you already are. Furthermore, you'll have at least two places you have to look to find the correct display logic for your label, rather than just one.</p> <p>Remember that there is no absolute requirement to use the <code>LabelFor()</code> helper - you can just as well just roll your own extension method on <code>HtmlHelper</code>, or even ignore them and output plane HTML:</p> <pre><code>&lt;label for="Person_HomeAddress"&gt;Home address&lt;/label&gt; &lt;!-- the ID might be wrong --&gt; &lt;%: Html.EditorFor(m =&gt; m.HomeAddress) %&gt; </code></pre> <p>Since the <code>EditorFor()</code> outputs an ID matched to the name of the model and property names, you'll be fine.</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. This table or related slice is empty.
    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