I put a tabIndex=0 on my textbox and tabIndex=1 for a button.
The focus is on my textbox. After the first Tab, it also jumps to the URL address and get to my button only on the second tab.
I believed the problem comes from the fact that each control has a default Tabindex set to 0. I updated it to another value and the problem still remains.
Anybody can help us ?
Thanks.

Hi, in tag Form add these method :
defaultbutton and defaultfocus.

Every time you hit enter in textbox control, it directly triggers your button click event.

<form id="form1" runat="server" defaultbutton ="TxtFind" defaultfocus ="CmdFind">

Hopely solve your problem.

Thanks,

Kusno

i used those defaultbutton & defaultfocus in form, with the help of these i got some result but in this case, when i press tabbutton after entering username in 1st textbox the control gos to address bar of the browser.
so i want to focus that control in passord textbox
tell me how to solve it??

thanx

hi

this also works.

/////// Code to set focus to a control in asp.net////////

	<form id="Form1" method="post" runat="server">
			<asp:Button id="tbErrorGenerator" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 216px"
				runat="server" Text="Button"></asp:Button>
			<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 296px; POSITION: absolute; TOP: 144px"
				runat="server"></asp:TextBox>
				 <script>window.document.all("TextBox1").focus()</script>

		</form>

used those defaultbutton & defaultfocus in form, with the help of these i got some result but in this case, when i press tabbutton after entering username in 1st textbox the control goes to address bar of the browser.
so after filling 1st textbox ,without going to address bar i want to focus in passord textbox
tell me how to solve it??

thanx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.