Link在验证摘要信息 [英] Link in validation summary message

查看:127
本文介绍了Link在验证摘要信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能把在验证摘要信息HTML链接?例如,我想提出一个链接到另一个页面,以防有验证错误:

Is it possible to put a HTML link in validation summary message? For example I want to put a link to another page in case there is validation error:

@Html.ValidationSummary(False, "read <a href=""anotherpage.html"">more</a>")

@Html.ValidationSummary(False, "read " &
    Html.ActionLink("more", "helpforerror").ToHtmlString)

但是,在浏览器中的标签被转义因此它不会形成连结

But in the browser the tag is escaped so it doesn't form a link.

推荐答案

最后,我选择了另一种方式来做到这一点:创建一个包含验证摘要以外的链接等一个div,并添加DIV只有ModelState中是无效的:

Finally I chose another way to do it: create a div containing the link etc. outside of validation summary, and add the div only if modelstate is not valid:

@If Not ViewData.ModelState.IsValid Then
    @<div>read <a href="anotherpage.html">more</a></div>
End If

这是由<一个启发href=\"http://stackoverflow.com/questions/10267515/show-div-if-unobtrusive-validation-was-invalid-and-hide-it-if-valid-in-mvc-3/10267912#10267912\">an回答类似的问题。

这篇关于Link在验证摘要信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆