加载视图并发送数据 [英] Load view and send it data
本文介绍了加载视图并发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以问任何问题吗?
当我的控制器功能出现错误或真实结果时,我会形成下一条消息:
Can i ask any question?
When i get false or true result by my function at controller, i form next message:
ModelState.AddModelError("", "Wrong ID parametr");
然后返回View(Index);
但是这个构造只返回我的空视图,因为不是调用方法,填充数据并将返回它我发现另一个是:用户重定向:
and then return View("Index");
But this construction return me only empty View, because was not call method, that fill data and will return it to view.
I found another was: user redirect:
return RedirectToAction("Index");
但是这样我就得不到了来自ModelState的消息。
这个范围有一些方法吗?
But in this way i do not get message from ModelState.
There are some methods for this scope?
推荐答案
你应该调用源代码(进入私有方法)将填写您的数据对于名为yourModel的对象的视图,然后返回View(Index,yourModel);
You should invoke the source code (into a private method) that will fill your data for the view into an object named "yourModel", then "return View("Index", yourModel);"
这篇关于加载视图并发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文