Retrieving url provided by sf:DetailsViewHyperLink
Hi,
I got a custom Module with a media field.
In my AssetField Control, I would like to create a link to the default Page (same link as sf:DetailsViewHyperLink) if the media field is not filled.
How can I get the url provided by "sf:DetailsViewHyperLink" control?
Thanks for your help.
Hello Loris,
Can you please elaborate a little bit more on your case - What do you mean by "a link to the default Page" - the canonical URL of the item or the hyperlink to details view for current ContentView control?
If you want to put an extra link in the template of the Assets Field, you will have to create a custom field extending the current ImageAssetsField and add it to the template, and then add a DetailsViewHyperLink there.
It comes to my sight that you are using Sitefinity 7.0. Does this mean that you are using the Related media field? If this is the case, please check the following paragraph of the upcoming Related Data documentation:
<
div
>
<
ul
>
<
asp:Repeater
runat
=
"server"
DataSource='<%# Container.DataItem.GetRelatedItems("SponsorLogos") %>'>
<
ItemTemplate
>
<
li
><
a
href='<%# Eval("MediaUrl") %>'>
<
img
height
=
"95"
src
=
"<%# Eval("
ThumbnailUrl")%>" alt="<%# Eval("AlternativeText")%>" id="<%# Eval("Id") %>" title="<%# Eval("Title") %>" >
</
a
></
li
>
</
ItemTemplate
>
</
asp:Repeater
>
</
ul
>
</
div
>
Note: You should import the following namespace:
<%@ Import Namespace="Telerik.Sitefinity.RelatedData" %>
<%@ Import Namespace="Telerik.Sitefinity.Libraries.Model" %>
Hello Kristian,
Thank you for your answer.
I created a new module called "Specific News" with a media field (file), a text zone, etc.
In the widget template which displays the list of "Specific News", I would like to use the link provided by the "sf:DetailsViewHyperLink" control if the media field is not filled.
I don't know if this is possible. But anyway I found another way to do what I would like :
<
sf:DetailsViewHyperLink
ID
=
"DetailsViewHyperLink"
TextDataField
=
"Title"
runat
=
"server"
Visible='<%# (Eval("Content") == null || Eval("Content").Equals(string.Empty)) ? false : true %>' /><
uc:AssetsFieldCustom
ID
=
"customAssetsField"
runat
=
'server'
DataFieldName
=
'pdf_File'
Visible='<%# (Eval("Content") == null || Eval("Content").Equals(string.Empty)) ? true : false %>' Description='<%# Eval("Title")%>'/>