This is a migrated thread and some comments may be shown as answers.

Use RadBinaryImage as a hyperlink button

2 Answers 180 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
John Hadjioannou
Top achievements
Rank 1
John Hadjioannou asked on 04 Jul 2009, 02:36 PM
I'm using a RadBinaryImage in a repeater to display a list of images from a db table.  I'd like to make the images "clickable", redirecting to a url specified in the database row.  Is there a way of setting the ImageUrl of a hyperlink to the RadBinaryImage - or some other way of achieving this?

Thanks
John

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 06 Jul 2009, 10:47 AM
Hello John,

This can be done by wrapping the RadBinaryImage instance inside an anchor tag and specifying the href of the anchor using a binding expression, for example:

        <asp:Repeater runat="server" ID="Repeater1" DataSourceID="SqlDataSource2">  
            <ItemTemplate> 
                <fieldset style="float: left; width: 350px; height: 150px;">  
                    <legend><b>Company Name</b>:  
                        <%#Eval("CompanyName")%></legend>  
                    <div class="details">  
                        <div class="photo-container">  
                          <a href='<%# Eval("<SourceFieldUrl>")%>'>  
                            <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("Photo") %>' 
                                AutoAdjustImageControlSize="false" Width="90px" Height="110px" ToolTip='<%#Eval("ContactName", "Photo of {0}") %>' 
                                AlternateText='<%#Eval("ContactName", "Photo of {0}") %>' /> 
                           </a>
                        </div> 
                        <div class="data-container">  
                            <ul> 
                                <li> 
                                    <label> 
                                        Contact Name:</label> 
                                    <%#Eval("ContactName")%> 
                                </li> 
                                <li> 
                                    <label> 
                                        Title:</label> 
                                    <%#Eval("ContactTitle")%> 
                                </li> 
                                <li> 
                                    <label> 
                                        City:</label> 
                                    <%#Eval("City")%> 
                                </li> 
                                <li> 
                                    <label> 
                                        Country:</label> 
                                    <%#Eval("Country")%> 
                                </li> 
                                <li> 
                                    <label> 
                                        Phone:</label> 
                                    <%#Eval("Phone")%> 
                                </li> 
                            </ul> 
                        </div> 
                    </div> 
                </fieldset> 
            </ItemTemplate> 
        </asp:Repeater> 
        <div style="clear: both;">  
        </div> 
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:TelerikConnectionString.ProviderName %>" 
            SelectCommand="SELECT TOP 6 * FROM [CustomerPhotos]"></asp:SqlDataSource> 
 

where <SourceFieldUrl> is the name of the database field which holds the url.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
John Hadjioannou
Top achievements
Rank 1
answered on 06 Jul 2009, 02:37 PM
Thank you!

John
Tags
BinaryImage
Asked by
John Hadjioannou
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
John Hadjioannou
Top achievements
Rank 1
Share this question
or