RadComboBox postback with the same content

2 posts, 0 answers
  1. Jhonny
    Jhonny avatar
    1 posts
    Member since:
    Feb 2013

    Posted 18 Feb 2013 Link to this post

    Hello, how I can make a RadComboBox do postback
    That each time you press the ENTER key.

    When I have the same content does not postback.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Feb 2013 Link to this post

    Hi Jhony

    Try the following markup and JS to achieve your scenario.
    aspx:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientKeyPressing="OnClientKeyPressing" OnClientFocus="OnClientFocus">
        <Items>
            <telerik:RadComboBoxItem Text="001" Selected="true" />
            <telerik:RadComboBoxItem Text="002" />
            <telerik:RadComboBoxItem Text="003" />
        </Items>
    </telerik:RadComboBox>
    JS:
    <script type="text/javascript">
    var comboText;
    function OnClientFocus(sender, args)
    {
        comboText = sender.get_text();
    }
    function OnClientKeyPressing(sender, args)
    {
        if (comboText == sender.get_text())
        {
        //No postback
        }
        else
        {
            if (args.get_domEvent().keyCode == 13)
            {
                __doPostBack();
            }
        }
    }
    </script>

    Thanks
    Princy
Back to Top