Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default submit buttons not getting focus when user clicks inside textbox.

Status
Not open for further replies.

sirnose1

Programmer
Nov 1, 2005
133
US
I have a form with 2 text boxes and two submit buttons. When I click in textbox1, the focus needs to be set to button1 and with textbox2, the focus needs to be set to button2 as the submit keys. I have been through the forums and they all say that this should work, however its' not working for me. I can't see what I am doing wrong. Please advise. Thanks in advance.

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:panel ID="P1" runat="server" DefaultButton="Button1">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"
TabIndex="1" />
</asp:panel>
<asp:panel ID="P2" runat="server" DefaultButton= "Button2" >
<asp:TextBox ID="TextBox2" runat="server" TabIndex="2"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click"
TabIndex="3" />
</asp:panel>

</asp:Content>
 
There was nothing wrong. I assumed it didnt work because the button never got focus
 

You'll have to use JavaScript to shift focus from one control to another while it's on the client machine. The DefaultButton property indicates which button gets clicked when the Panel control has focus and the user presses the ENTER key, not the one that actually gets the focus.


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top