I'm working with EPiServer since september now and I'm using more advanced features now but I'm stuck with something and I'd really love if someone can help me.
I have made a custom HTML Helper to use with Razor MVC to be able to use display options without having to create a custom ContentAreaRendered and everything that seems to go with it but any links I use in my view are internal ugly url (aspx stuff) and if I have any method that are supposed to transform this ugly URL into a friendly URL it does not work.
Here is part of my block model:
[CultureSpecific]
[Display(
Name = "Link",
Description = "Link for the button",
GroupName = SystemTabNames.Content,
Order = 30)]
[BackingType(typeof(PropertyUrl))]
public virtual Url URL { get; set; }
[CultureSpecific]
[Display(
Name = "Image (Optional)",
Description = "An optional image to display under the description",
GroupName = SystemTabNames.Content,
Order = 40)]
[UIHint(UIHint.Image)]
public virtual ContentReference Image { get; set; }
Here is my Helper:
public static XhtmlString RowFromArea(this HtmlHelper html, Expression> expression)
{
var returnString = "";
var area = ModelMetadata.FromLambdaExpression(expression, html.ViewData).Model as ContentArea;
if (area != null)
{
returnString += "
";
foreach (ContentAreaItem item in area.FilteredItems)
{
var block = item.GetContent();
// LoadDisplayOption(item);
returnString += "
You see I have an image that is a ContentReference and a Link that is can be either to an internal page or an external URL. And I get only ugly URL. I'm using the same
@Url.ContentUrl(Model.URL) in another view that is not passing through my helper and it's working properly so I think the problem is coming from something I missed in my helper.
For info, I just fixed my bug. My helper was returning a XhtmlString and apparently for the UrlHelper to properly do its jobs you need to return a MvcHtmlString.
Hi,
I'm working with EPiServer since september now and I'm using more advanced features now but I'm stuck with something and I'd really love if someone can help me.
I have made a custom HTML Helper to use with Razor MVC to be able to use display options without having to create a custom ContentAreaRendered and everything that seems to go with it but any links I use in my view are internal ugly url (aspx stuff) and if I have any method that are supposed to transform this ugly URL into a friendly URL it does not work.
Here is part of my block model:
Here is my Helper:
Here is the page view where I call the actual helper:
And this is what I have in my block partial view:
You see I have an image that is a ContentReference and a Link that is can be either to an internal page or an external URL. And I get only ugly URL. I'm using the same