c# - Nested ViewModels / Partial View problems in MVC -


I have two ideas: a partial view, and a scene that is partial view using @ html Surrounds "_PartialView") . Each has its own view modal:

  public square partial visual model {// property, etc} public class MainViewModel {public partial ViewModel p {get; Set; } // properties, etc.}  

When I load the second view (which uses the main visual model), then I'm getting dictionary errors, because this view and Partial view captures it Using two different view models, I can not use them with the same view modal, because partial views are presented inside many other different scenes.

To be clear, in view of this, representing all the fields shared partially between the form, do I have an option, or am I trying to do something which MVC does not fit within the lack of design?

You want to design it slightly differently. The main scene will have a model - lets call it mainmodel , and a partial view can be a model - we call it a partial model call

  Public Class Partial Modal {/// Propet} Public Segment Main View Model {Partial Partial {Partial Receipt; Set; } // properties, etc. // Other comments in reply to this public MainViewModel () {partial = new partial modal}; }}  

Then your main view will be

  @model mainviewmodel  

Then in the middle of the main see that your Something like this is

  @ {Html.RenderPartial ("myPartialView", Model.Partial); }  

Note the braces around HTML. Render partial they are necessary because the render-particle return is zero.

When you present a partial view you can also pass it in the model, if it is prepared properly then partial requirements are already accessible from the main view model.


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? -