MVC2 Custom HTML Helper and <%:%> Syntax

Can I use a custom html helper with the syntax <%:%>?

I know that if I use the code below, this is normal, but it does not seem so elegant and safe.

<%= Html.MyHelper("Some Data")%>

I mean using <% =%> is best practice?

+3
source share
2 answers

Ask your assistant to return MvcHtmlStringinstead of a string. Also, please use <%: as much as possible.

+3
source

HTML- HTML, , , <%= %>. <%: %> HTML- HTML-, HTML, , (, <input name="foo" value="bar"> ), , , , .

HTML- . , HTML- - HTML-, - . , , , HTML-.

Microsoft, , -, , tutorial :

return String.Format("<label for='{0}'>{1}</label>", target, text);

. , ID !

[ - ?]

0

Source: https://habr.com/ru/post/1763615/


All Articles