วันจันทร์ที่ 28 พฤศจิกายน พ.ศ. 2559

HTML Helpers in ASP.NET MVC5

The following table lists HtmlHelper methods and html control each method generates.

HtmlHelperStrogly Typed HtmlHelpersHtml Control
Html.ActionLinkAnchor link
Html.TextBoxHtml.TextBoxForTextbox
Html.TextAreaHtml.TextAreaForTextArea
Html.CheckBoxHtml.CheckBoxForCheckbox
Html.RadioButtonHtml.RadioButtonForRadio button
Html.DropDownListHtml.DropDownListForDropdown, combobox
Html.ListBoxHtml.ListBoxFormulti-select list box
Html.HiddenHtml.HiddenForHidden field
PasswordHtml.PasswordForPassword textbox
Html.DisplayHtml.DisplayForHtml text
Html.LabelHtml.LabelForLabel
Html.EditorHtml.EditorForGenerates Html controls based on data type of specified model property e.g. textbox for string property, numeric field for int, double or other numeric type.
The difference between calling the HtmlHelper methods and using html tags is that the HtmlHelper method is designed to make it easy to bind to view data or model data.
Press CTRL + Spacebar to autocomplete the Helper. 
Press CTRL + SHIFT + Spacebar to show the parameter options.