Default setting for SelectionOnFocus?

3 posts, 0 answers
  1. Allin
    Allin avatar
    33 posts
    Member since:
    Jun 2012

    Posted 30 Oct 2013 Link to this post

    Hi,

    Actually, the defaut is 'None'

    I try to find a setting to set SelectionOnFocus="SelectAll" by defaut for all input into my application. Is it possible without parse all webpage to make manually the change?

    ty
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 31 Oct 2013 Link to this post

    Hi Allin,

    The Default is "None" for RadTextBox and it is set to "SelectAll" for NumericTextBox.

    Yes you can change it globally, using a ControlAdapter.

    Create an RadInputAdapter.cs with the content below and place inside App_Code folder in your site.
    using System;
    using System.Web.UI.Adapters;
    using Telerik.Web.UI;
    public class RadInputAdapter : ControlAdapter
    {
        protected override void OnLoad(EventArgs e)
        {
            var input = this.Control as RadInputControl;
            if (input != null)
            {
                input.SelectionOnFocus = SelectionOnFocus.SelectAll;
            }
     
            base.OnLoad(e);
        }
    }

    Now in the App_Browsers folder create an default.browser with this content:
    <browsers>
      <browser refID="Default">
        <controlAdapters>
          <adapter
            controlType="Telerik.Web.UI.RadTextBox"
            adapterType="RadInputAdapter"
          />
          <adapter
            controlType="Telerik.Web.UI.RadNumericTextBox"
            adapterType="RadInputAdapter"
          />
          <adapter
            controlType="Telerik.Web.UI.RadMaskedTextBox"
            adapterType="RadInputAdapter"
          />
          <adapter
            controlType="Telerik.Web.UI.RadDateInput"
            adapterType="RadInputAdapter"
          />
        </controlAdapters>
      </browser>
    </browsers>

    I hope this helps.

    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allin
    Allin avatar
    33 posts
    Member since:
    Jun 2012

    Posted 31 Oct 2013 Link to this post


    Hello Vasil,

    Exactly what i need.

    Thank you very much!!
Back to Top