AutoPostback not setting focus correctly

3 posts, 1 answers
  1. larry reames
    larry reames avatar
    6 posts
    Member since:
    Feb 2010

    Posted 30 Dec 2010 Link to this post

    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. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Jan 2011 Link to this post

    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.
  3. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Jan 2011 Link to this post

    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.
Back to Top