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

AutoPostback not setting focus correctly

2 Answers 92 Views
Input
This is a migrated thread and some comments may be shown as answers.
larry reames
Top achievements
Rank 1
larry reames asked on 30 Dec 2010, 04:23 PM

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" />

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();
           
}
       
}
}

2 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 04 Jan 2011, 01:46 PM
Hi,

Please note that adding RadAjaxPanel into the RadAjaxManager settings or use the both controls for updating the same part of the page is totally incorrect and not supported and may lead to a lot of different issues. Also I would suggest you to use the Focus() method of RadAjax in order to correctly place the focus where needed.


Kind regards,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Accepted
Maria Ilieva
Telerik team
answered on 04 Jan 2011, 01:46 PM
Hi,

Please note that adding RadAjaxPanel into the RadAjaxManager settings or use the both controls for updating the same part of the page is totally incorrect and not supported and may lead to a lot of different issues. Also I would suggest you to use the Focus() method of RadAjax in order to correctly place the focus where needed.


Kind regards,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Input
Asked by
larry reames
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or