Autopostback only when list item selected and not text entered

4 posts, 1 answers
  1. andieje
    andieje avatar
    473 posts
    Member since:
    Oct 2006

    Posted 07 Jul 2009 Link to this post

    Hi

    I am using a combo box where the user can enter custom text. I have set the auto postback property to true.

    I would like the combo box to function such that it only posts back when the user changes the selection from the drop down list and not when they enter custom text.

    Please can you tell me how to achieve this

    Many thanks
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Jul 2009 Link to this post

    Hello,

    One suggestion would be invoking postback from client side SelectionIndexChanged event of RadComboBox instead of setting the AutoPostBack property to True. Give a try with the following code.

    ASPX:
     
    <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="false" AllowCustomText="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged" 
        OnClientSelectedIndexChanged="OnClientSelectedIndexChanged"
        <Items> 
            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1"
            </telerik:RadComboBoxItem> 
               . . . 
        </Items> 
    </telerik:RadComboBox> 

    JavaScript:
     
    <script type="text/javascript"
    function OnClientSelectedIndexChanged(sender, args) 
        __doPostBack('RadComboBox1','');  
    </script> 

    -Shinu.
  3. andieje
    andieje avatar
    473 posts
    Member since:
    Oct 2006

    Posted 07 Aug 2009 Link to this post

    many thanks
  4. TRACI
    TRACI avatar
    1 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    Wonderful!  My AutoPostBack is set to "true" and I'm calling the correct server side method, but the postback was never firing, until I added your Client Side javascript call to postback. 

    Thank you so much!!!
Back to Top