0
在ASP.NET 4.5 Web窗体应用程序中使用Web Forms MVP框架时,如何从该页面的Presenter
对象内获取对页面的ModelStateDictionary对象的引用?如何从Web窗体MVP Presenter中获取对Web窗体的ModelStateDictionary的引用?
我希望我的演示者能够在出现问题时设置模型状态错误。例如:尝试插入违反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”产生的相关结果的低得惊人数量。