ForeColor in the TilePeekTemplate

2 posts, 0 answers
  1. steve gray
    steve gray avatar
    14 posts
    Member since:
    Mar 2006

    Posted 05 Sep Link to this post

    Sirs:

    I'm trying to dynamically set the font color in the TileList PeekTemplate. The code that I'm using is below (and it works), but Visual Studio generates 7 warning for the syntax. Is there a better way? I can't seem to access that property in the TileDataBound event.

    <telerik:RadTileList runat="server" ID="RadTileList1" TileRows="1" >
        <DataBindings>
            <CommonTileBinding  TileType="RadTextTile" DataNavigateUrlField="NavigateUrl"  />
            <TextTileBinding  DataTextField="Module_Name"    />
            <TilePeekTemplate  >
                <div style="font-size:20px; width:150px;color:<%# DataBinder.Eval(Container.DataItem, "TileColor") %>">
                    <div><%# DataBinder.Eval(Container.DataItem, "ModuleID") %></div>
                    <div style="font-size:14px"><%# DataBinder.Eval(Container.DataItem, "NumberOfTables") %></div>
     
                </div>
            </TilePeekTemplate>
     
        </DataBindings>
    </telerik:RadTileList>       

     

     

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3599 posts

    Posted 07 Sep Link to this post

    Hi Steve,

    There shouldn't be an issue with this approach. Nevertheless, you can consider using CSS classes for the desired colors if there is a limited number of values instead of the inline style attribute.

    As for doing that in the TileDataBound event—the styles collection of a server control can be used, or a Panel's properties. For example:

    protected void RadTileList1_TileDataBound(object sender, TileListEventArgs e)
    {
        Panel pnl = e.Tile.PeekContentContainer.FindControl("Panel1") as Panel;
        pnl.ForeColor = Color.FromName(DataBinder.GetPropertyValue(e.Tile.DataItem, "TileColor", null));
    }

    <TilePeekTemplate>
        <asp:Panel ID="Panel1" runat="server" Font-Size="20px" Width="150px">
     
            <div><%# DataBinder.Eval(Container.DataItem, "ModuleID") %></div>
            <div style="font-size: 14px"><%# DataBinder.Eval(Container.DataItem, "NumberOfTables") %></div>
        </asp:Panel>
     
    </TilePeekTemplate>

    Regards,

    Marin Bratanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top