Remove tab stop from RadNumericTextBox spin buttons

4 posts, 0 answers
  1. Drew
    Drew avatar
    13 posts
    Member since:
    Nov 2007

    Posted 02 Nov 2009 Link to this post

    All,

    I have multiple web pages that each contain 36 radNumericTextboxes on them.

    I want to disable the tab stop on the spin buttons for each of the controls. So far the only answer I can find is this:

    myControl.ButtonDownContainer.Attributes.Add("tabindex", "-1")
    myControl.ButtonUpContainer.Attributes.Add("tabindex", "-1")

    I don't want to have 72 lines of code on each of my 19 pages to do something that I should be able to do in a for each loop. However, I cant seem to implement the following code because the telerik controls dont exist in system.web.ui.page

    For Each myControl In Page.Controls
                If TypeOf myControl Is RadNumericTextBox Then
                    myControl.ButtonDownContainer.Attributes.Add("tabindex", "-1")
                    myControl.ButtonUpContainer.Attributes.Add("tabindex", "-1")
                End If
    Next

    So my question is, how can I return an array of all telerik controls contained on a page?

    Thank you,
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 03 Nov 2009 Link to this post

    Hi Drew,

    Yes, the RadNumericTextBoxes do not reside in the Page.Controls collection. Page.Controls contains some LiteralControls and one HtmlForm control, nothing more. You can see that by debugging your code.

    In other words, you need to iterate through the page controls' collections recursively.

    Another approach is to apply the tabindex attribute client-side. This can be achieved by obtaining a collection of all <a> elements on the page, check whether any of them has a "riDown" or "riUp" CSS class and set the tabindex attribute.

    Javascript

    Sys.Application.add_load(setTabIndex);
     
    function setTabIndex()
    {
        var hyperlinks = document.getElementsByTagName("a");
        for (var j = 0; j < hyperlinks.length; j++)
        {
            if (hyperlinks[j].className.indexOf("riUp") != -1 || hyperlinks[j].className.indexOf("riDown") != -1)
                hyperlinks[j].setAttribute("tabindex", "-1");
        }
    }



    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Drew
    Drew avatar
    13 posts
    Member since:
    Nov 2007

    Posted 03 Nov 2009 Link to this post

    Awesome,

    My biggest problem was actually scope related.
    Any time I tried to reference anything on Me.Form.Controls or Me.page.Controls the system was only returning controls from the master page.

    I ended up fixing the problem by using this solution we came up with here:

    Dim cph As ContentPlaceHolder = CType(HttpContext.Current.Handler, Page).Form.FindControl("cph"
     
    For Each mycontrol As Control In cph.Controls  
       If TypeOf mycontrol Is Telerik.Web.UI.RadNumericTextBox Then 
          Dim ntb As RadNumericTextBox = DirectCast(mycontrol, RadNumericTextBox) 
          ntb.ButtonDownContainer.Attributes.Add("tabindex""-1")
          ntb.ButtonUpContainer.Attributes.Add(
    "tabindex""-1"
       End If 
    Next 


    Cheers
  5. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 29 Jun 2015 in reply to Drew Link to this post

    Thanks Drew,

     

    Yes, just add it in the _PreRender will also work fine:

    Dim ntb As RadNumericTextBox = DirectCast(mycontrol, RadNumericTextBox)
    ntb.ButtonDownContainer.Attributes.Add("tabindex", "-1")
    ntb.ButtonUpContainer.Attributes.Add("tabindex", "-1")

    Erik

Back to Top