I get my hands on MVC 3 and am confused about how to use UserControls in my project.
I created a usercontrol (cshtml) file called UserControl.cshtml and I am trying to make it Product.cshtml.
MyUserControl.cshtml is located in the shared folder.
In Products.cshtml:
<div> @Html.Partial("MyUserControl.cshtml"); </div>
But I get this error. I do not know why it is trying to find the .ascx file .:
The partial view 'MyUserControl.cshtml' was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Products/MyUserControl.cshtml.aspx ~/Views/Products/MyUserControl.cshtml.ascx ~/Views/Shared/MyUserControl.cshtml.aspx ~/Views/Shared/MyUserControl.cshtml.ascx
Is usercontrol in mvc 3 doing this right?
- Update -
It works.
@RenderPage("../Shared/MyUserControl.cshtml")
Asdfg source share