AI OnAI Off
Dont think that htmlhelper exist out-of-the-box in Episerver.
Here is an example of one to get you started:
public static class HtmlHelperExtensions { public static MvcHtmlString PageLinkText(this HtmlHelper htmlHelper, ContentReference pageLink, object htmlAttributes, string htmltag = "span") { if (ContentReference.IsNullOrEmpty(pageLink)) return MvcHtmlString.Empty; var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>(); var tagBuilder = new TagBuilder(htmltag??"span"); var page = contentLoader.Get<PageData>(pageLink); tagBuilder.InnerHtml = HttpUtility.HtmlEncode(page.PageName); var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); tagBuilder.MergeAttributes(attributes); return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal)); } }
...and you can now use it in your .cshtml like:
@Html.PageLinkText(Model.CurrentPage.PageLink,new {@class="cssclass-without-link"})
Added the possiblility to send along attributes for your containing element and also configure what that element should be.
Another option is of course to add this to your viewmodel instead and resolve the text for the link in the controller instead using pretty much the same code.
First of all, I am not super knowledgeable in Epi or C#. I am displaying links into my navigation using @Html.PageLink(). This pulls the entire for each link. However, I don't want some levels of my nav to show as links - just text. So how can I pull out the label (name of the page for each link) and display in the nav as just a span or whatever? Thanks for any help!