0

私はプログラミングにかなり慣れていないので、ばかげている場合は申し訳ありませんが、特定の例外がキャッチされた場合に複合キー違反のためにメッセージが表示される 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");
                }

ありがとう...

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 に答える