Help to look for Control

P

PABLIN

Hello Friends, I need to look for a control can be Web
Form or Html Form, by means of the TabIndex property, how
I can do it?
 
A

Alvin Bruney

all controls on a form are part of the form controls collection. loop thru
that looking for the form's id as an identifier.
 
K

Ken Cox [Microsoft MVP]

Assuming you are using the tabindex property, you can loop through the controls
on the form using server-side code to pick out the control's tabindex and set
other values.

Here's a little demo:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim cntrl As Control
Dim txtcntrl As TextBox
For Each cntrl In Page.Controls(1).Controls
If TypeOf cntrl Is System.Web.UI.WebControls.TextBox Then
txtcntrl = cntrl
If txtcntrl.TabIndex = 1 Then
Button1.Text = "The Textbox is tabindex " & _
txtcntrl.TabIndex.ToString
End If
End If
Next
End Sub


<form id="Form1" method="post" runat="server">
<p>
<asp:button id="Button1" tabindex="5" runat="server"
text="Button"></asp:button></p>
<p>
<asp:checkbox id="CheckBox1" tabindex="2"
runat="server"></asp:checkbox></p>
<p>
<asp:textbox id="TextBox1" tabindex="1"
runat="server"></asp:textbox></p>
<p>
<asp:imagebutton id="ImageButton1" tabindex="9" runat="server"
imageurl="http://www.gc.ca/images/rollingflag.jpg"></asp:imagebutton></p>
</form>


Does this help?

Ken
MVP [ASP.NET]


Hello Friends, I need to look for a control can be Web
Form or Html Form, by means of the TabIndex property, how
I can do it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top