ASP.NET 4.5 Web フォーム アプリケーションでWeb フォーム MVPフレームワークを使用して、そのページのオブジェクト内からページのModelStateDictionaryオブジェクトへの参照を取得するにはどうすればよいPresenter
ですか?
何か問題が発生した場合に、プレゼンターがモデル状態エラーを設定できるようにしたいと考えています。例: UNIQUE 制約に違反するレコードを挿入しようとしたときのエラー。
try
{
dbcontext.SaveChanges();
}
catch (DbUpdateException updateException)
{
// how to get a reference to the model state?
ModelStateDictionary state = null;
// add the error to the model state for display by the view
state.AddModelError("key", updateException.GetBaseException().Message);
}
「 webformsmvp presenter modelstatedictionary 」を Google 検索すると、驚くほど少ない数の関連する結果が得られます。