ASP.Net MVC UserControl in View with different controller?
I am trying to create a usercontrol that is an extremely simple form. This usercontrol will appear in a number of different views in my app. I am thoroughly confused on how this can be accomplished.
I have created a controller, and then created a usercontrol that uses that controller.
I then created another controller and created a view for an index of that controller. Inside this view i added my usercontrol reference:
<% Html.RenderPartial("~/Views/UserControlController/Create.ascx"); %>
When i attempt to navigate to 开发者_开发百科the view i can see that the actionresult method for the usercontrol in UserControlController is never called.. What am i missing?? thanks for any help.
Ok, I see your problem. Dont Render partial, you want render action. Whats the difference? Render Partial should read RenderPartialView, not RenderPartialAction. If you want to execute the action, you need Html.RenderAction.
精彩评论