Try our conversational search powered by Generative AI!

Edit on page Url


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?

Mar 26, 2014 16:08

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:

Edited, Mar 26, 2014 21:43

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?

Mar 28, 2014 10:46

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.

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.