SelectedText change after OnClientBlur

4 posts, 1 answers
  1. Avelyn Teh
    Avelyn Teh avatar
    10 posts
    Member since:
    May 2010

    Posted 25 Mar 2011 Link to this post

    Hi Telerik Team,

    RadCombobox selected text have change after selected and click somewhere on page.
    I notice that this happening when items are same value. If value are unique this will not happening.

    Please test the following code.
    If select "ccc" or "ddd" and click somewhere the selected text will change to "aaa"
    If select "222" or "333" and click somewhere the selected text will change to "111"

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <telerik:RadComboBox ID="CboPOL" Runat="server">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="aaa" Value="First" />
                <telerik:RadComboBoxItem runat="server" Text="bbb" Value="First" />
                <telerik:RadComboBoxItem runat="server" Text="ccc" Value="First" />
                <telerik:RadComboBoxItem runat="server" Text="ddd" Value="First" />
                <telerik:RadComboBoxItem runat="server" Text="eee" Value="First" />
                <telerik:RadComboBoxItem runat="server" Text="111" Value="Second" />
                <telerik:RadComboBoxItem runat="server" Text="222" Value="Second" />
                <telerik:RadComboBoxItem runat="server" Text="333" Value="Second" />
                <telerik:RadComboBoxItem runat="server" Text="abc" Value="third" />
                <telerik:RadComboBoxItem runat="server" Text="hij" Value="forth" />
            </Items>
        </telerik:RadComboBox>
         
        </div>
        </form>
    </body>
    </html>
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 25 Mar 2011 Link to this post

    Hello Avelyn Teh,

    RadComboBox items need to have unique values - please find more details about this topic at "RadComboBox selects a different item" help article.


    Best wishes,
    Kalina
    the Telerik team
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Mar 2011 Link to this post

    Hello Avelyn Teh,

    As Kalina said the RadComboBox items need to have unique values. If you still want to use the RadComboBoxItems with same values then one option is to use CustomAttributes. You can access this value either from server side or client side. Here is a sample code.

    aspx:
    <telerik:RadComboBox ID="CboPOL" Runat="server" OnClientBlur="OnClientBlur">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="aaa" customValue="First"  />
                <telerik:RadComboBoxItem runat="server" Text="bbb" customValue="First" />
                <telerik:RadComboBoxItem runat="server" Text="ccc" customValue="First" />
                <telerik:RadComboBoxItem runat="server" Text="ddd" customValue="First"  />
                <telerik:RadComboBoxItem runat="server" Text="eee" customValue="First" />
                <telerik:RadComboBoxItem runat="server" Text="111" customValue="Second"  />
                <telerik:RadComboBoxItem runat="server" Text="222" customValue="Second" />
                <telerik:RadComboBoxItem runat="server" Text="333" customValue="Second"/>
                <telerik:RadComboBoxItem runat="server" Text="abc" customValue="Third" />
                <telerik:RadComboBoxItem runat="server" Text="hij" customValue="First" />
            </Items>
    </telerik:RadComboBox>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    C#:
    protected void Button1_Click(object sender, EventArgs e)
       {
           string value  = CboPOL.SelectedItem.Attributes["customValue"].ToString(); //accessing the custom attribute value
           Response.Write(value);
       }

    Thanks,
    Shinu.
  5. Avelyn Teh
    Avelyn Teh avatar
    10 posts
    Member since:
    May 2010

    Posted 28 Mar 2011 Link to this post

    Dear Shinu,

    Thank you for your brilliant suggestion.
Back to Top