在剃刀mailto链接 [英] MailTo link in Razor
本文介绍了在剃刀mailto链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
怎么办?
我见过Html.MailTo,但是当我试图@ Html.MailTo没有出现。
I've seen Html.MailTo, but when I try @Html.MailTo nothing comes up.
谢谢!
推荐答案
HTML.MailTo()辅助是'MVC3期货项目的一部分,但就是这样一个替代做到这一点。
HTML.MailTo() helper is a part of the 'mvc3 futures' project, but there is an alternative to way to do it.
1)创建APP_ code目录中一个新的.cshtml文件,只要你想它命名(例如HTMLHelpers.cshtml)
1.)Create a new .cshtml file inside App_Code directory and name it as you want (for example HTMLHelpers.cshtml)
2)写入文件中的以下
2.)Write the following in the file
@helper EmailTextBox(string email, string title) {
<a href="mailto:@email">@title</a>
}
3)现在,在你看来,你可以叫你的新功能。比如写
3.)Now in your view you can call your new function. For example write
Email: @HTMLHelpers.EmailTextBox("george@example.com","George Chatzimanolis")
这篇关于在剃刀mailto链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文