This is a migrated thread and some comments may be shown as answers.

Autopostback only when list item selected and not text entered

3 Answers 291 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
andieje
Top achievements
Rank 1
andieje asked on 07 Jul 2009, 03:14 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 08 Jul 2009, 07:20 AM
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.
0
andieje
Top achievements
Rank 1
answered on 07 Aug 2009, 11:30 AM
many thanks
0
TRACI
Top achievements
Rank 1
answered on 29 Sep 2011, 09:21 PM
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!!!
Tags
ComboBox
Asked by
andieje
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
andieje
Top achievements
Rank 1
TRACI
Top achievements
Rank 1
Share this question
or