ASP.Net MVC: How do I Reuse Views and Partials With Different Models? -


I need to show different form fields based on the type of user I'm saving.

I have some user types and some user types have the same data, so you can imagine the following:

  1. TypeA: name, password, < TypeC: Name, Password, LinkedIn, LinkedType SystemC, Legacy System CUSIRID, Legacy System Sea Level Level
  2. < Li>

When I create a new user I can be in the context of any of these systems, but I Sector know that I am connected to how the system (a specific controller Siarudi each user), but I want to share ideas (if possible). So I have found: TypeAUserController, TypeBUserController, TypeCUserController, create, retrieve, update, and delete / remove / post actions of each one yourself.

So the basic question is "How can I reuse the view to display for each user?"

Edit: And For clarification, there is shared information for each user, this is the view that I want to share. The ideas that I had taken up to date, believe that the difference between the model will be partially explained and each potential model has its own view. That's why we are seeing a page-level model for each CRUD operation on the user and then a single pipeline for each child model that encompasses differences, it is not already a good approach to the reasons listed below. Possible Solution 1: Pass this Model

  • CreateUserPageModel

  • LegacySystemModel
  • LegacySystemCodel
  • Partial Name
  • Ul>

    Then use partial name to use partial name in the scene and to select non-null model to pass it

    When submitting the form it will be stored on a page with a custom model binder that must be selected correctly model.

    Benefits:

    • Permission to view parents was reused
    • Differences in model are kept in separate partial < Cons:

      • The child's model filling must be passed
      • Partial name has to be passed and one in the controller Path must be selected

    Comments

    Popular posts from this blog

    apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

    c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

    c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -