I have a macro that is being used to loop through a media type full of carousel images. That part, as well as the if statement defining which image I really want, is working beautifully as a banner. My problem is that the banner is supposed to have breadcrumbs over top that allow the user to go back a page in the directory. The code is a little complicated, so it's in a partial in an attempt to make things cleaner. The partial won't render. Right now, I have it commented out so that I can work with the macro, but as soon as I uncomment it the macro breaks. This is how I'm trying to render the partial: @Html.Partial("_BreadCrumbs")
I've tried researching this, but no matter what keywords I use my searches bring up how to render a macro inside a partial... which is the complete opposite of what I want. Also, the code I'm using to render the partial is the same code I would be using in a Template, which works.
This article helped me understand the problem more, but the solutions posed here haven't solved anything for me... The error that I keep getting is: Error loading Partial View script (file: ~/Views/MacroPartials\_BannerPicker.cshtml)
I've since fixed the mixed slash issue, but when I try to force the directory like that it still doesn't work... Is the directory case-sensitive? Also, what exactly does the little tilde do? The directories actually look like below... I just omitted the one layer because I didn't think it was important.
Views
MacroPartials
SiteName
BannerPicker.cshtml (the macro I'm working with)
Partials
SiteName
BreadCrumbs.cshtml (the partial I'm trying to display inside it)
Rendering a Partial inside a Macro
Hi,
I have a macro that is being used to loop through a media type full of carousel images. That part, as well as the if statement defining which image I really want, is working beautifully as a banner. My problem is that the banner is supposed to have breadcrumbs over top that allow the user to go back a page in the directory. The code is a little complicated, so it's in a partial in an attempt to make things cleaner. The partial won't render. Right now, I have it commented out so that I can work with the macro, but as soon as I uncomment it the macro breaks. This is how I'm trying to render the partial:
@Html.Partial("_BreadCrumbs")
I've tried researching this, but no matter what keywords I use my searches bring up how to render a macro inside a partial... which is the complete opposite of what I want. Also, the code I'm using to render the partial is the same code I would be using in a Template, which works.
This article helped me understand the problem more, but the solutions posed here haven't solved anything for me... The error that I keep getting is: Error loading Partial View script (file: ~/Views/MacroPartials\_BannerPicker.cshtml)
Hi Emmali,
your sample above looks slightly wrong, you have mixed slashes. Rendering a partial inside a macro should be as simple as:
Hopefully this helps?
Mark
Hi Mark,
I've since fixed the mixed slash issue, but when I try to force the directory like that it still doesn't work... Is the directory case-sensitive? Also, what exactly does the little tilde do? The directories actually look like below... I just omitted the one layer because I didn't think it was important.
My code looks like this:
If I comment out the above line of code the macro works just fine, so I know it's an issue connecting the two.
Hi Emmali,
Little tilde should move start of your traversing to root folder of web application.
Directory names are not case-sensitive.
I think you can try to render your partial like:
Because Partial is looking int Partials folder by default.
Thanks,
Alex
is working on a reply...