0

I am new to MVC and I can't seem to find the answer I am looking for, probably because of not using the correct terminology to search.

I am trying to load a static menu navigation in my ASP.NET MVC View (which is a widget template in Sitefinity CMS).

In Web Forms, this was an easy task by registering a User Control in the widget template like this:

<%@ Register TagName="SecNav" TagPrefix="CustomNav" Src="~/CustomWidgets/SecondaryNav.ascx" %>

And then in the body of my Widget template I could call the control like this:

<ul>
  <CustomNav:SecNav runat="server" />
</ul>

What is the equivalent method of the above in ASP.NET MVC View?

hnnnng
  • 481
  • 4
  • 21
  • In MVC you have Partial Views, but you will need to provide the correct model to that view. What exactly are you trying to achieve? – Veselin Vasilev Jul 28 '21 at 23:24
  • Thanks @VeselinVasilev, I'll look that up. I have a bunch of Views (for my Detail pages) and they all share the same secondary navigation code. I was wondering how to template the navigation and utilize it in my Views, so it can be managed/edited in one location instead of various places. – hnnnng Jul 29 '21 at 13:15
  • Okay, so I am able to pull and display my navigation with this in my Detail View: @Html.Partial("~/Mvc/Views/Shared/BookstoreSecNav.cshtml"), but is there a better way by not specifying the full path? Maybe by adding a @using statement? – hnnnng Jul 29 '21 at 15:19
  • You can try just @Html.Partial("BookstoreSecNav") and Sitefinity will automatically look for it in the Shared folder. – Veselin Vasilev Jul 30 '21 at 00:21

0 Answers0