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.Foo
is not of the view , then the user codemodel < / Code> will be equivalent to
Model.Foo
, andModel.Foo
ofModel.Foo
of UserControl. - * If the
Model.Foo
is null of the view, then themodel of UserControl
, andmodel
Model.Foo
of the UserControl will beModel.Foo
. If the view'smodel
andmodels Fu
is not the same type and view themodel
is absent and if the user controller uses the view typed strongly Ugrkantrol models now instead ofTViewModel
< Code> TUserControlModel
Comments
Post a Comment