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

Remove tab stop from RadNumericTextBox spin buttons

3 Answers 161 Views
Input
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 2
Drew asked on 02 Nov 2009, 10:35 PM
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,

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 03 Nov 2009, 02:40 PM
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.
0
Drew
Top achievements
Rank 2
answered on 03 Nov 2009, 03:39 PM
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
0
Erik
Top achievements
Rank 2
answered on 29 Jun 2015, 10:35 AM

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

Tags
Input
Asked by
Drew
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Drew
Top achievements
Rank 2
Erik
Top achievements
Rank 2
Share this question
or