How can/should I create some \"custom control\" in ASP.NET MVC 3? I have red about partial views, ViewUsersControl
, Html.RenderAction
, but I still don\
You may use
@{Html.RenderPartial("YourCustomView",YourModel);}
For instance, In your Shared
folder create a new View
and name it "_MyCustomControl"
Then in the code write :
@model YourNameSpace.Models.YourModel
@{
Layout = null;
}
@*Here write your control's markup*@
Then in your Views where you want to use this "control"
you add:
@{Html.RenderPartial("_MyCustomControl",new YourModel { args });}
If you get into trouble with RenderPartial
check this out