0

如果我很愚蠢,我对编程很抱歉,但我正在编写一个 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");
                }

谢谢...

4

1 回答 1

1

您是否尝试过将错误更改为仅输出链接的原始 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>");
            }

你试过什么了?

于 2011-11-17T20:29:18.550 回答