views:

12

answers:

1

Hi All,

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.

A: 

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.

CrazyDart
Hi Thanks for responding!! I am getting this error:
toddm
A public action method '~/Views/EmotionPost/Create.ascx' was not found on controller 'Emotion.Controllers.UserController'. this usercontrol has a different controller than it's parent view.. not sure if this is an issue??
toddm
am i going about this wrong?? should usercontrols have different controllers? Keeping in mind my usercontrol will appear on different views?
toddm
OK i got it.. syntax for renderaction was wrong (on my part)
toddm
for people that might feel slow like me: Html.RenderAction(put action name in here with quotes, put controller name in here with quotes WITHOUT "controller" in the name) -- yes newb issue
toddm