473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Tab order & postback confusion

I am sure there is an easy answer to this, so here goes...

Imagine a web form consists of two text boxes and some labels. The textboxes
are given a tab order of 1 & 2, and each posts back to the server
ontextchanged. What actually happens in practice is this:

I change text in textbox1.
I press tab to go on to textbox 2.
Focus (ie blinking cursor) moves to textbox2.
Form then blinks (presumably as trip to server is made as per
textbox1.ontextchanged).
Textbox2 then loses focus (in fact nothing seems to have focus).

It seems to me that the trip back to the server is defeating the object of
having a tab order. How do I get the form to come back from the server with
focus still where it should be (ie in textbox2 in this example)?

Thanks a lot.

--
John Wilson
Nov 19 '05 #1
1 3066
John,

Yes, the postback is defeating tab order in this instance. Each post back
the page is brand new so you get tab 1.

The way to handle this is in the text box's on text changed event. You can
use a javascript to set the focus to the next control.

E.g. in the first textbox's on text changed:

Page.RegisterStartupScript("TextBoxFocus", "<script
language=""javascript"">document.getElementById('" & TextBox2.ClientId &
"').focus();</script>")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"John Wilson" <JW@AdviceNet.com> wrote in message
news:43***********************@news.aaisp.net.uk.. .
I am sure there is an easy answer to this, so here goes...

Imagine a web form consists of two text boxes and some labels. The
textboxes are given a tab order of 1 & 2, and each posts back to the
server ontextchanged. What actually happens in practice is this:

I change text in textbox1.
I press tab to go on to textbox 2.
Focus (ie blinking cursor) moves to textbox2.
Form then blinks (presumably as trip to server is made as per
textbox1.ontextchanged).
Textbox2 then loses focus (in fact nothing seems to have focus).

It seems to me that the trip back to the server is defeating the object of
having a tab order. How do I get the form to come back from the server
with focus still where it should be (ie in textbox2 in this example)?

Thanks a lot.

--
John Wilson

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
4
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
1
by: William_Woods | last post by:
The goal is to have a new web page called from a dropdown component. HTML: <asp:dropdownlist id="drpPacer" runat="server" ForeColor="Navy" Width ="372px" AutoPostBack="True"></asp:dropdownlist>...
2
by: Mark Rae | last post by:
I've inherited an ASP.NET app and have been asked to fix the following problem with a page which is used to display and/or delete records from a database. When the page loads, it displays a list of...
11
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be...
12
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
3
by: Tony | last post by:
I see that many pages have &amp; in querystring instead &. What is difference? Can I put page link (url) www.mysite.com/mypage.aspx?lang=EN&ID=15 or I need to write...
1
by: aRTx | last post by:
<? /* Directory Listing Script - Version 2 ==================================== Script Author: Artani <artan_p@msn.com>. www.artxcenter.com REQUIREMENTS ============ This script requires...
1
by: Brit | last post by:
I have an ASP file that retrieves names from an Access database for 4 different categories of membership, which the visitor to the page selects (corporate, institutional, regular, or student). The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.