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

Eval not being evaluated for URLtoShare

1 Answer 65 Views
SocialShare
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 20 Jan 2012, 07:29 AM
I have the following in a template for a listview, the title is being evaluated and bound as expected, but the URLToShare is not?
<ItemTemplate>
            <div class="keyTagData">
                     
                <div id="KeyTagLogo">
                    <img id="imgKeyTagLogo" <%#FormatImageData(Eval("OfferGroup.Enterprise.LogoFile").ToString())%> alt='<%#Eval("OfferGroup.Enterprise.DBAName")%>' />
                    <%--<asp:Image runat="server" ID="imgKeyTagLogo" ImageUrl='~/CouponLogos/<%#Eval("OfferGroup.Enterprise.LogoFile")%>' />--%>
                </div>
                <div id="KeyTagHeader">
                    <%#Eval("OfferGroup.Enterprise.DBAName")%>
                </div>
                <div id="KeyTagText">
                    <%#Eval("Title")%>
                </div>
                <div id="KeyTagSocialMedia">
                    <telerik:RadSocialShare ID="radSocialMediaKeyTag" runat="server" CssClass="DblUpFB"
                    TitleToShare='<%#Eval("Title")%>' UrlToShare='http://www.mydomain.com/Detail.aspx?ogid=<;%=Eval("OfferGroupID").ToString()%>'>
                        <MainButtons>
                            <telerik:RadSocialButton SocialNetType="ShareOnFacebook" />
                            <telerik:RadSocialButton SocialNetType="ShareOnTwitter" />
                            <telerik:RadSocialButton SocialNetType="SendEmail" />
                        </MainButtons>
                    </telerik:RadSocialShare>
                </div>
                <div id="KeyTagNumOffers"><a href='Detail.aspx?ogid=<%#Eval("OfferGroupID")%>'><%#((int)Eval("OfferGroup.Offers.Count")-1).ToString()%> More Offers</a></div>
                <div id="KeyTagPrint">
                    <asp:ImageButton runat="server" ID="btnPrint" OnClientClick='<%#FormatJS(Eval("OfferGroupID").ToString())%>' ImageUrl="~/images/InsidePage_PrintButton.png" />
                </div>
            </div>
        </ItemTemplate>

 

 

 

 

Sys.Application.add_init(

function() {

$create(Telerik.Web.UI.RadSocialShare, {

"_addFbScript":false,"_addGoogleScript":false,"_addTwitterScript":false,"_uniqueId":"ctl00$ContentPlaceHolder1$radDiscountList$ctrl1$radSocialMediaKeyTag","clientStateFieldID":"ctl00_ContentPlaceHolder1_radDiscountList_ctrl1_radSocialMediaKeyTag_ClientState","mainButtons":"[['ShareOnFacebook','http://www.doubleupdiscounts.com/Detail.aspx?ogid=<%=Eval("OfferGroupID").ToString()%>','Free Pizza on Us!', '470', '470', '', ''],['ShareOnTwitter','http://www.mydomain.com/Detail.aspx?ogid=<%=Eval("OfferGroupID").ToString()%>','Free Pizza on Us!', '470', '470', '', ''],['SendEmail','http://www.mydomain.com/Detail.aspx?ogid=<%=Eval("OfferGroupID").ToString()%>','Free Pizza on Us!', '470', '470', '', '']]"}, null, null, $get("ctl00_ContentPlaceHolder1_radDiscountList_ctrl1_radSocialMediaKeyTag"));

});

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 24 Jan 2012, 10:56 AM
Hello Ryan,

The RadSocialShare code has additional evaluations and encoding for the url in order to resolve relative url and also to prevent javascript errors. That is why you should change your syntax in the following manner:

<telerik:RadSocialShare ID="radSocialMediaKeyTag" runat="server" CssClass="DblUpFB"
  
                    TitleToShare='<%#Eval("Title")%>'
 
UrlToShare='<%# Eval("OfferGroupID", "http://www.mydomain.com/Detail.aspx?ogid={0}") %>'>

 This syntax is not specific but the general standard way to use Eval in more complex scenarios. You can also find it in our online demos, e.g below:

http://demos.telerik.com/aspnet-ajax/tooltip/examples/loadondemand/defaultcs.aspx

where the image is evaluated in this manner.

Please, test my suggestion and let me know whether it works for you.

All the best,
Svetlina Anati
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
SocialShare
Asked by
Ryan
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or