如何解决向实体框架代码中添加html操作链接,首先添加AddModelError字符串
|| 我对编程很陌生,所以如果我很愚蠢,对不起,但是我正在编写一个ASP.Net MVC3应用程序,其中如果捕获到特定异常,则会由于复合键冲突而显示一条消息。 我可以捕获异常,但是在消息中,我想添加一个操作链接来编辑未通过键冲突测试的数据。 在以下示例中,我无法解决如何使用链接。如何使“ HERE”成为操作链接? catch (DataException)
{
if (duplicateKeyAttempt == true)
{
ModelState.AddModelError(\"\",\"A delivery charge already exists for this combination of customer type and delivery method. \" +
\"Please check the information you have provided,this selection cannot be saved. \" +
\"If you want to edit the existing database entry,click HERE\");
}
谢谢...
解决方法
您是否尝试过更改Error以仅输出链接的原始HTML,如下所示:
if (duplicateKeyAttempt == true)
{
ModelState.AddModelError(\"\",\"A delivery charge already exists for this combination of customer type and delivery method. \" +
\"Please check the information you have provided,this selection cannot be saved. \" +
\"If you want to edit the existing database entry,click <a href=\\\"url\\\">HERE</a>\");
}
你都尝试了些什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。