MVC2自定义HTML帮助程序和语法(MVC2 Custom HTML Helper and Syntax)

编程入门 行业动态 更新时间:2024-10-22 12:35:07
MVC2自定义HTML帮助程序和<%:%>语法(MVC2 Custom HTML Helper and <%: %> Syntax)

有没有办法使用<%:%>语法的自定义html助手?

我知道,如果我使用下面的代码,那没关系,但它看起来并不那么优雅和安全。

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

我的意思是,使用<%=%>是最佳做法?

Is there any way to use a custom html helper with the <%: %> syntax ?

I know that if i'm use the code below, it's ok, but it's seems not so elegant and secure.

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

I mean, use <%= %> is the best practices?

最满意答案

让你的助手返回一个MvcHtmlString而不是一个字符串。 另外,请尽可能使用<%:

Have your helper return an MvcHtmlString instead of a string. Also, please use <%: as much as possible.

更多推荐

本文发布于:2023-04-29 02:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334545.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   语法   程序   HTML   Helper

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!