开发者

MVC 2 partial for edit/create return error

I got a question about MVC 2 and returning views for partials:

I got two views for creating and editing a user, the views both uses a partial so i can reuse the form fields. UserPartial.ascx, EditUser.aspx, CreateUser.aspx

I got some logic in the controller post method (EditCreateUser) which finds out if its a new or existing user which is beeing submitted and this works fine.

The problem is when I try to return the edited user: return View(user). MVC complains about EditCreateUser file not existing. But thats only the method name, i want to return the object to the EditUser view which I am already on.

I could use RedirectToAction but i rather not because this problem would occur also if i want to return the same object when some errors has occured.

Any ideas on how to do this or some pointers in the right direction w开发者_如何学Goould be awesome. Thanks


Within an action method named EditCreateUser, the statement return View(user) will by default look for a view with the same name as the action. You need return View("EditUser", user)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜