12
Custom HTML Helpers in ASP.NET MVC Lohith G N

Creating Custom HTML Helpers in ASP.NET MVC

Embed Size (px)

Citation preview

Page 1: Creating Custom HTML Helpers in ASP.NET MVC

Custom HTML Helpers in ASP.NET MVC

Lohith G N

Page 2: Creating Custom HTML Helpers in ASP.NET MVC

About Me

Technical EvangelistMicrosoft MVP (ASP.NET/IIS)

[email protected]

@kashyapahttp://www.kashyapas.com

http://www.telerikhelper.net

Lohith G N

http://www.telerik.com

Page 3: Creating Custom HTML Helpers in ASP.NET MVC

Agenda

• Understanding HTML Helpers

• Standard Helpers in ASP.NET MVC

• Writing Custom Helpers

Page 4: Creating Custom HTML Helpers in ASP.NET MVC

Understanding HTML Helpers

Page 5: Creating Custom HTML Helpers in ASP.NET MVC

HTML Helpers

Source: Wikipedia

• Method that returns String

• Avoid tedious typing of HTML Tags

• Render any content using Helpers

Page 6: Creating Custom HTML Helpers in ASP.NET MVC

Standard Helpers in MVC

Page 7: Creating Custom HTML Helpers in ASP.NET MVC

Standard HTML Helpers

• @Html.Label(), @Html.LabelFor()

• @Html.TextBox(), @Html.TextBoxFor()

• @Html.TextBox(), @Html.TextBoxFor()

• @Html.DropDownList(), @Html.DropDownListFor()• …

Page 8: Creating Custom HTML Helpers in ASP.NET MVC

Demo

Page 9: Creating Custom HTML Helpers in ASP.NET MVC

Custom HTML Helpers

Page 10: Creating Custom HTML Helpers in ASP.NET MVC

Developing Custom HTML Helpers

• @helper

• Static Methods

• Extension Methods

• Fluent Extension Methods

Page 11: Creating Custom HTML Helpers in ASP.NET MVC

Demo