Eval not being evaluated for URLtoShare

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    1 posts
    Member since:
    Jan 2012

    Posted 20 Jan 2012 Link to this post

    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"));

    });

  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 24 Jan 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top