본문 바로가기

트레이닝

HTML Helpers

HTML Helpers가 무엇인지, Razor View 에서 HTML Helpers를 사용하는 방법에 대해 알아보기로 합니다.

HtmlHelper 클래스는 Razor View 에서 HTML 컨트롤을 렌더링한다. 모델 객체를 HTML 컨트롤에 바인딩하여 모델 속성 값을 해당 컨트롤에 표시하고 웹 폼을 표시하면서 모델 속성에 컨트롤 값을 할당하기도 한다.

 

 

HTML은 HtmlHelper Razor View 의 기본 클래스 이며, ActionLink(), DisplayNameFor() 등은 HtmlHelper 클래스 확장 함수입니다.  HtmlHelper 클래스는 HTML 요소를 생성합니다. 

예를 들어, @Html.ActionLink("Create New", "Create") 앵커 태그 생성 <a href="/Student/Create">Create New</a>.

 

다음 표는 HtmlHelper메소드는 HTML을 렌더링한다.

확장 함수 Collection 확장 함수 렌더링 Html
Html.ActionLink() NA <a></a>
Html.TextBox() Html.TextBoxFor() <input type="textbox">
Html.TextArea() Html.TextAreaFor() <input type="textarea">
Html.CheckBox() Html.CheckBoxFor() <input type="checkbox">
Html.RadioButton() Html.RadioButtonFor() <input type="radio">
Html.DropDownList() Html.DropDownListFor() <select>
<option>
</select>
Html.ListBox() Html.ListBoxFor() multi-select list box: <select>
Html.Hidden() Html.HiddenFor() <input type="hidden">
Html.Password() Html.PasswordFor() <input type="password">
Html.Display() Html.DisplayFor() HTML text: ""
Html.Label() Html.LabelFor() <label>
Html.Editor() Html.EditorFor() Generates 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.

HtmlHelper 메소드를 사용하는 것은 모델에 데이터를 표시 하거나 쉽게 바인딩할 수 있도록 설계되었다.

 

참조 - https://www.tutorialsteacher.com/mvc/html-helpers

 

HTML Helpers in ASP.Net MVC

HTML Helpers Here, you will learn what HTML helpers are and how to use them in the razor view. The HtmlHelper class renders HTML controls in the razor view. It binds the model object to HTML controls to display the value of model properties into those cont

www.tutorialsteacher.com

 

'트레이닝' 카테고리의 다른 글

Razor HtmlHelper - TextArea  (0) 2021.02.17
Razor HtmlHelper - Textbox  (0) 2021.02.17
Razor 문법  (0) 2021.02.15
블레이저 앱 개발을 위한 환경 설정  (0) 2021.02.15
블레이저란 무엇인가?  (0) 2021.02.14