开发者

AccountModel in one screen

I have this app with basic AccountModel that ships with MVC3. The AccountModel have three classes:

  • ChangePasswordModel;
  • LoginModel;
  • RegisterModel;

I want to create an Account/Settings screen so I've create the Settings Action on the Account Controller.

But I can't realize wha开发者_运维百科t to do next since this screen will have all account funcionts like change password, change site settings and profile stuff and the ChangePasswordModel is a separate model!

How to post the ChangePassword form inside this /Account/Settings and still get the ChangePassword action working?

How to unify this in one screen?


If you wrap each set of functionality in a new form then you can accomplish what you want... You can use

<% using(Html.BeginRouteForm(...) %>

to pretty cleanly specify where you would like each section of the page to go... I would recommend that you send each to different actions (even if they are in the same controller) so as to keep your model binding simpler.

This can get ugly if you have var A in one form but want to retrieve it in a different form.

So long as you want to just put everything on the same screen each form can successfully represent their own model cleanly then this is a pretty decent way to do this (IMO)

EDIT

If you're used to ASP.net and MVC is a little new to you, putting multiple forms on the same page is against the ASP.net nature, but in mvc (as mentioned) you can do this very effectively.

EDIT for Links

http://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginrouteform.aspx

http://msmvps.com/blogs/luisabreu/archive/2009/01/31/the-mvc-platform-more-form-extension-methods.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜