November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
There is no way to determine a target for a single link item when you only have a property of type Url.
When you have a LinkItemCollection, you have a list of "LinkItem". A LinkItem have the attribute selected by the editor stored to Target.
For example
@foreach(LinkItem item in CurrentPage.MyLinkItemCollection)
{
<a href="@Html.GetFriendlyURL(item.Href)" @(!String.IsNullOrEmpty(item.Target) ? "target=\"" + @item.Target + "\"" : "")>@item.Text</a>
}
Given that you have an Extension method on HtmlHelper called GetFriendlyURL. Note that Target is usually empty, hence you need to check the value before rendering the target-attribute or you will render target="".
If you want to render a complete link including the href, target and text without any custom html or attributes, you could use @Html.PageLink(item)
Thanks for your reply, Yes URL alone we can't do anything and also Epi not allows LinkItem as a separate property type.
So, is there any possible way to control the number of link item to Linkitemcollection property ?
For example; at this scenario, the end-user needs to add only one item into the LInkitemcollection proerty.
You can build a validator attribute of your own, you can find some inspiration on http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2013/1/Limiting-a-Page-Property-to-a-specific-Page-Type-in-EPiServer-7/
Personaly I think I would create a Block that contains a Url, Target and Text instead of the entire functionality you will get from the LinkItemCollection.
I need to set the Target from the URL property. Please find the below My code snippet
[Editable(true)]
[Display(
Name = "Twitter URL",
Description = "Twitter URL property",
GroupName = TabNames.Footer,
Order = 400)]
public virtual Url TwitterURL { get; set; }
In the above code I need to get and assign the "Ahref" Target value.
I have also used "LinkItemCollection" for getting more LinkItems. So that I can get the Target value, like below.
string aHref = @Html.GetFriendlyURL(null, @Footernav2.Href);
<a href="@aHref" target="@Footernav2.Target">@Footernav2.Text</a>
The same way, I need to get the Target value for the single Link Item. Kindly help to achive this.