Change Token colors

2 posts, 0 answers
  1. Ratzai
    Ratzai avatar
    14 posts
    Member since:
    Oct 2007

    Posted 12 Nov 2012 Link to this post

    I have tried to change the ForeColor and BackColor of a RACB token, but the styling doesn't appear when i add the tokens. Is it not possible to change the colors from code-behind?

    Here is my code:

    foreach (string chemical in chemicalsArrayList)
        AutoCompleteBoxEntry entry = new AutoCompleteBoxEntry();
        chemicalBC = BCFactory.ChemicalBC;
        DataSet dsClassifications = chemicalBC.GetClassificationByChemicalName(chemical);
        entry.Text = chemical;
        if (dsClassifications.Tables[0].Rows.Count != 0)
            entry.ToolTip = dsClassifications.Tables[0].Rows[0][0].ToString();
            entry.ForeColor = System.Drawing.ColorTranslator.FromHtml("#" + dsClassifications.Tables[0].Rows[0]["Color"].ToString());
            entry.ToolTip = "";
  2. Kalina
    Kalina avatar
    918 posts

    Posted 15 Nov 2012 Link to this post

    Hi Ratzai,

    Changing the background color of a RadAutoCompleteBox entry is not a supported scenario.

    However you can try implementing client-side logic with JavaScript and change it.
    I can suggest you handle the OnClientEntryAdding event and add a custom CSS to the entry token element in this way:

    <head runat="server">
         <style type="text/css">
             div.RadAutoCompleteBox_Default .racBlueToken
                background-color: #25A0DA;
                border-color: #25A0DA;
                color: #000;
         <script type="text/javascript">
            function onClientEntryAdded(sender, eventArgs)
                var $ = $telerik.$;
                var entry = eventArgs.get_entry();
                var tokenElement = eventArgs.get_entry().get_token();
                if(entry.get_text() == "Andrew")
        <form id="form1" runat="server">
            <asp:ScriptManager ID="manager" runat="server"></asp:ScriptManager>
                <telerik:RadAutoCompleteBox runat="server" ID="RadAutoCompleteBox2"
                    DataSourceID="SqlDataSource1" OnClientEntryAdded="onClientEntryAdded"
                    AllowCustomEntry="true"  DataTextField="FirstName" InputType="Token">
              <asp:SqlDataSource runat="server" ID="SqlDataSource1"
                   ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>"
                  SelectCommand="SELECT [FirstName], [LastName], [EmployeeID] FROM [Employees]" />

    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.
Back to Top