将 html 操作链接添加到实体框架 Code First AddModelError 字符串
我对编程还很陌生,如果我很愚蠢,很抱歉,但我正在编写一个 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");
}
谢谢...
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. " +
"If you want to edit the existing database entry, click HERE");
}
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过更改错误以仅输出链接的原始 HTML,如下所示:
到目前为止您尝试过什么?
Have you tried changing the Error to just output the raw HTML for the link like this:
What have you tried so far?