PDA

View Full Version : Html.Label



مهدی هادیان2
سه شنبه 07 آبان 1392, 22:15 عصر
بسم الله الرحمن الرحیم
با سلام
لطفا راجع به مطلب زیر توضیح بدید.
Html.Label
The Label helper returns a <label/> element using the string parameter to determine the rendered
text and for attribute value. A different overload of the helper enables you to independently set the
for attribute and the text. In the preceding code, the call to Html.Label("GenreId") produces the
following HTML:
<label for="GenreId">Genre</label>
If you haven’t used the label element before, then you are probably wondering if the element has
any value. The purpose of a label is to attach information to other input elements, such as text
inputs, and boost the accessibility of your application. The for attribute of the label should contain
the ID of the associated input element (in this example, the drop-down list of genres that follows
in the HTML). Screen readers can use the text of the label to provide a better description of
the input for a user. Also, if a user clicks the label, the browser will transfer focus to the associated
input control. This is especially useful with checkboxes and radio buttons in order to provide the
user with a larger area to click on (instead of being able to click only on the checkbox or radio button
itself).
The attentive reader will also notice that the text of the label did not appear as “GenreId” (the string
you passed to the helper), but as “Genre.” When possible, helpers use any available model metadata in
building a display. We’ll return to this topic once you’ve looked at the rest of the helpers in the form.
با سپاس فراوان