Form items selection order in .NET
I have a Form with 5 textbox. When I press tab I want each of them to be selected in a particular order like tbox1, 开发者_如何学编程tbox5, tbox2,...
How do I do it?
You'll want to set the .TabIndex
property on the controls.
This will allow you to set the order in which they are focused when tabbing through the UI. Keep in mind, however, that there is no unique constraint on this property among the controls. You can set multiple controls to have the same TabIndex
and the ordering of those particular controls would revert back to whatever it would be by default with no explicit tab ordering.
You need to set the tab index of each element. You can set this in the Visual Studio designer.
Set the TabIndex property of the text box control.
<asp:TextBox ID="txtFirstName" runat="server" CssClass="txtRegForm" MaxLength="50" TabIndex="1"></asp:TextBox>
<asp:TextBox ID="txtLastName" runat="server" CssClass="txtRegForm" MaxLength="50" TabIndex="2"></asp:TextBox>
<asp:TextBox ID="txtStreetName" runat="server" CssClass="txtRegForm" MaxLength="50" TabIndex="3"></asp:TextBox>
The value in tab index decides the orde to switch from one text box to another
精彩评论