I have found all controls of a page and set tabindex, you can try like this...
or please explain your exact requirement
public static void SetTabIndex(ref Panel panelcontainer)
{
int tabindex = 1;
foreach (System.Web.UI.Control ctrl in panelcontainer.Controls)
{
if (ctrl.ID != null)
{
if (ctrl is TextBox)
{
((TextBox)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is Button)
{
((Button)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is RadioButtonList)
{
((RadioButtonList)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is ImageButton)
{
((ImageButton)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is CheckBox)
{
((CheckBox)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is DropDownList)
{
((DropDownList)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is HyperLink)
{
((HyperLink)ctrl).TabIndex = (short)tabindex;
tabindex++;
}
else if (ctrl is System.Web.UI.HtmlControls.HtmlImage)
((System.Web.UI.HtmlControls.HtmlImage)ctrl).Attributes.Add("tabindex", tabindex.ToString());
else if (ctrl is System.Web.UI.HtmlControls.HtmlAnchor)
((System.Web.UI.HtmlControls.HtmlAnchor)ctrl).Attributes.Add("tabindex", tabindex.ToString());
}
}
}