hello,
i have two RadComboBoxes on my page: CarMake, CarModel. when the user selects a CarMake, it initiates a callback via an RadAjaxManager and updates the list collection on CarModel via code-behind.
this works.
however, a problem -- my users use a keyboard and need to tab from one item to the next. currently after the callback completes and the second RadComboBox is bound, the focus is lost..it defaults to the top of the page. no good. ive tried setting the focus in my callback code-behind, but it does nothing.
1) how can i set the focus after an ajax databind?
2) is this how i should be doing the ajax-goodness? or should it use client-side events & handlers?
my ASPX
code-behind
thanks!
matt
i have two RadComboBoxes on my page: CarMake, CarModel. when the user selects a CarMake, it initiates a callback via an RadAjaxManager and updates the list collection on CarModel via code-behind.
this works.
however, a problem -- my users use a keyboard and need to tab from one item to the next. currently after the callback completes and the second RadComboBox is bound, the focus is lost..it defaults to the top of the page. no good. ive tried setting the focus in my callback code-behind, but it does nothing.
1) how can i set the focus after an ajax databind?
2) is this how i should be doing the ajax-goodness? or should it use client-side events & handlers?
my ASPX
| <Telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <%-- Make updates Model --%> |
| <Telerik:AjaxSetting AjaxControlID="rcbVehicleMake"> |
| <UpdatedControls> |
| <Telerik:AjaxUpdatedControl ControlID="rcbVehicleModel" /> |
| </UpdatedControls> |
| </Telerik:AjaxSetting> |
| </AjaxSettings> |
| </Telerik:RadAjaxManager> |
| <span class="formLabel">Make:</span><br /> |
| <!-- by setting AutoPostBack=true, and using the AjaxManager, we can make this auto-update the Model list --> |
| <Telerik:RadComboBox ID="rcbVehicleMake" DataValueField="MakeCode" DataTextField="Description" Width="150" DropDownWidth="200" ShowToggleImage="false" AllowCustomText="False" MarkFirstMatch="true" OnSelectedIndexChanged="rcbVehicleMake_SelectedIndexChanged" AutoPostBack="true" runat="server"/> |
| <br/><br/> |
| <span class="formLabel">Model:</span><br /> |
| <Telerik:RadComboBox ID="rcbVehicleModel" DataValueField="ModelID" DataTextField="Description" Width="80" DropDownWidth="125" ShowToggleImage="false" AllowCustomText="False" MarkFirstMatch="true" runat="server" /> |
code-behind
| protected void rcbVehicleMake_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| SetVehicleModel(); |
| } |
| private void SetVehicleModel() |
| { |
| //clear old values |
| rcbVehicleModel.Items.Clear(); |
| rcbVehicleModel.Text = string.Empty; |
| string make = rcbVehicleMake.SelectedValue; |
| if (Strings.Exists(make)) |
| { |
| rcbVehicleModel.DataSource = Lookups.GetVehicleModelsByMake(make); |
| rcbVehicleModel.DataBind(); |
| rcbVehicleModel.Items.Insert(0, new RadComboBoxItem()); |
| //trying to set the focus..not working |
| rcbVehicleModel.Focus(); |
| Page.SetFocus(rcbVehicleModel); |
| } |
| } |
thanks!
matt