[英]Adding an html action link to an Entity Framework Code First AddModelError string
如果我很愚蠢,我对编程很抱歉,但我正在编写一个 ASP.Net MVC3 应用程序,如果捕获到特定异常,则会由于复合键违规而显示一条消息。
我可以捕获异常,但在消息中我想添加一个操作链接来编辑未通过密钥违规测试的数据。
我不知道如何在以下示例中使用链接。 如何使“这里”成为操作链接?
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");
}
谢谢...
您是否尝试将错误更改为仅 output 原始 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>");
}
你试过什么了?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.