将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.");
答案 0 :(得分: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
答案 1 :(得分: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());