开发者

Adding an html action link to an Entity Framework Code First AddModelError string

I am pretty new to programming so sorry if I'm being stupid, but I am writing an ASP.Net MVC3 application in which, if a particular exception is caught a message is displayed because of a composite key violation.

I can catch the exception but in the message I want to add an action link to edit the data that has failed the key violation test.

I can't work out how to use a link in following example. How can I make "HERE" an action link?

            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. " +
                  开发者_如何学Go      "If you want to edit the existing database entry, click HERE");
                }

Thanks...


Have you tried changing the Error to just output the raw HTML for the link like this:

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>");
            }

What have you tried so far?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜