November Happy Hour will be moved to Thursday December 5th.

Edit on page Url

Vote:
 

Trying to get my Url editable on preview page. Using MVC and I have sent my viewmodel to the view, and the property is of type Url and I have also used:

 

var editHints = ViewData.GetEditHints<ViewModel, MyBlock>();

 

My idea was to do like this:

<a href="@Html.PropertyFor(p=>p.Url.Path)">text</a>

 

But with no luck.

 

It works for my title.

 

Any idea?

#83152
Mar 26, 2014 16:08
Vote:
 

This is one approach you can do:

<a href="@Url.ContentUrl(Model.Url)" @Html.EditAttributes(p => p.Url)>text</a>

Also just using PropertyFor without tag should render proper tag, but it will use URL instead of text:

@Html.PropertyFor(p => p.Url)

 

This article describes how PropertyFor works:

http://joelabrahamsson.com/how-episervers-html-helper-propertyfor-works/

#83164
Edited, Mar 26, 2014 21:43
Vote:
 

Thanks for your answer!

What about making the link and the text editable at the same time? ever tried to get this solved in a nice way?

#83266
Mar 28, 2014 10:46
Vote:
 

I do not know how to do editing of link and text same time. It would be great if property of Url type would have also some Title field same as it is when you add link in TinyMCE editor.

#83282
Mar 28, 2014 13:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.