1

将 mailto 添加到此 ASP.NET MVC3 代码的正确语法是什么。这不起作用,使用双引号也不起作用:

ModelState.AddModelError("", "We could not locate the email address you entered.  Please check the email address.  If you believe it is correct, please contact us by sending an email to <a href='mailto:support@abc.com'>Support</a> from the email address you are attempting to use.");
4

2 回答 2

0

我不太擅长 Razor,但这暂时可以解决您的问题

@Html.Raw(Html.ValidationSummary().ToString().Replace("[mailto]", "<a href='mailto:support@abc.com'>Support</a>"))

你的消息将包含这个

ModelState.AddModelError("", "We could not locate the email address you entered.  Please
check the email address.  If you believe it is correct, please contact us by sending an 
email to [mailto] from the email address you are attempting to use.");

该链接现在添加到视图中,而不是从服务器/控制器中添加,[mailto]用实际链接替换您的链接并调用Html.Raw以在浏览器中呈现 html

于 2013-03-06T14:26:35.917 回答
0

尝试使用

添加这个 NamesPace :Using System.Text

    StringBuilder s=new StringBuilder ();
    s.Append(We could not locate the email address you entered.  Please check the email address.  If you believe it is correct, please contact us by sending an email to ");
    s.Append("<a href='mailto:support@abc.com'>Support</a>");
    s.Append("from the email address you are attempting to use.");
    ModelState.AddModelError("", s.ToString());
于 2013-03-06T14:37:06.583 回答