c# - pass an object to a user controls ViewModel in asp.net mvc -
I have a view that uses a specific view modal.
Various objects of the view modal eg. Foo, bar ... etc.
I have a user control, which has its own view modal in which Foo is the object.
How to pass the Foo object from the page View the usercontrols ViewModel?
If you do this:
& lt;% HTML .RenderPartial ("partial", model FU); & Gt%; Then one of the two things will be.
- If the
Model.Foois not of the view , then the user codemodel < / Code> will be equivalent toModel.Foo, andModel.FooofModel.Fooof UserControl. - * If the
Model.Foois null of the view, then themodel of UserControl, andmodelModel.Fooof the UserControl will beModel.Foo. If the view'smodelandmodels Fuis not the same type and view themodelis absent and if the user controller uses the view typed strongly Ugrkantrol models now instead ofTViewModel< Code> TUserControlModel
Comments
Post a Comment