I have a page that when auto or partial post back happens, focus is set to the address bar rather than the next control. The interesting thing is that when I put an alert in my RadScriptBlock, after the OK is clicked, focus goes to the correct control -or- if I put in an invalid location, focus is returned to the ExpLocation control & when a correct location is input the second time, the tab order/focus command works correctly (see code below).
That has this up top
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxPanel1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting EventName="OnTextChanged" AjaxControlID="RadNumericTextBox_GLm"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadNumericTextBox_GLm" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="lblGlCodeErrorMessage" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting EventName="OnTextChanged" AjaxControlID="RadNumericTextBox_ExpLocation"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="lblGlCodeErrorMessage" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="RadNumericTextBox_ExpLocation" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> That has this control..
<telerik:RadNumericTextBox ID="RadNumericTextBox_ExpLocation" runat="server" Width="20px" AutoPostBack="true" MaxLength="3" NumberFormat-AllowRounding="False" Type="Number" NumberFormat-KeepTrailingZerosOnFocus="True" IncrementSettings-InterceptMouseWheel="false" OnTextChanged="LocationCheck_OnTextChanged" TabIndex="101"> <NumberFormat DecimalDigits="0" GroupSeparator="" AllowRounding="false" KeepNotRoundedValue="false" /> with this code behind
protected void LocationCheck_OnTextChanged(object sender, System.EventArgs e) { var cmdText = "SELECT LMLOC FROM DBMOTO..XALOCNP WHERE " + " LMLOC = @ExpLocation "; using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MAINConnectionString"].ToString())) using (var cmd = new SqlCommand(cmdText, conn)) { cmd.Parameters.Add(new SqlParameter("@ExpLocation", RadNumericTextBox_ExpLocation.Text)); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { Session["ValidGL"] = false; lblGlCodeErrorMessage.Visible = false; lblGlCodeErrorMessage.Text = "Good Location"; btnAddItem.Enabled = false; btnDone.Enabled = false; RadNumericTextBox_GLm.Focus(); } else { lblGlCodeErrorMessage.Visible = true; lblGlCodeErrorMessage.Text = "Invalid/Inactive Location"; btnAddItem.Enabled = false; btnDone.Enabled = false; RadNumericTextBox_ExpLocation.Focus(); } } }