473,399 Members | 3,919 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,399 software developers and data experts.

Postback and Tab order

Hello,

I am doing web programming in VB ASP.NET. I have a group of fields that the
user can tab through in order and fill in info in each of the fields. Some
of the fields have code attached that runs when the value is changed in that
field. However, the problem is that when postback occurs to run this code,
it messes up the tab order for the user because, upon postsback, it starts
over and the first field in the list is where the tab starts again instead of
letting the user continue to continue tabbing down the list from where they
currently are. How can I get around this battle between postback and
taborder?

Thanks,
Dusty Hackney

Jan 11 '06 #1
4 1850
Dusty,

Use a javascript to set focus on the field. A startup script such as this:

Private Sub SetFocus(ByVal webControl As
System.Web.UI.WebControls.WebControl)
If Not page.IsStartupScriptRegistered("ControlFocus") Then
Dim StringBuilder As New System.Text.StringBuilder
With StringBuilder
..Append("<script language=""javascript"">" & vbCrLf)
..Append(vbTab & "<!--" & vbCrLf)
..Append(vbTab & vbTab & "document.getElementById('" & webControl.ClientID &
"').focus();" & vbCrLf)
..Append(vbTab & "//-->" & vbCrLf)
..Append("</script>" & vbCrLf)
End With
page.RegisterStartupScript("ControlFocus", StringBuilder.ToString)
End If
End Sub

If you call this sub each time a control posts back and use it to set focus
on the next control you should be all set. Of course this only solves the
problem you're having if the client is running javascript, but most should
be.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dusty Hackney" <Du**********@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hello,

I am doing web programming in VB ASP.NET. I have a group of fields that
the
user can tab through in order and fill in info in each of the fields.
Some
of the fields have code attached that runs when the value is changed in
that
field. However, the problem is that when postback occurs to run this
code,
it messes up the tab order for the user because, upon postsback, it starts
over and the first field in the list is where the tab starts again instead
of
letting the user continue to continue tabbing down the list from where
they
currently are. How can I get around this battle between postback and
taborder?

Thanks,
Dusty Hackney

Jan 11 '06 #2
Thanks for the quick response.
"S. Justin Gengo" wrote:
Dusty,

Use a javascript to set focus on the field. A startup script such as this:

Private Sub SetFocus(ByVal webControl As
System.Web.UI.WebControls.WebControl)
If Not page.IsStartupScriptRegistered("ControlFocus") Then
Dim StringBuilder As New System.Text.StringBuilder
With StringBuilder
..Append("<script language=""javascript"">" & vbCrLf)
..Append(vbTab & "<!--" & vbCrLf)
..Append(vbTab & vbTab & "document.getElementById('" & webControl.ClientID &
"').focus();" & vbCrLf)
..Append(vbTab & "//-->" & vbCrLf)
..Append("</script>" & vbCrLf)
End With
page.RegisterStartupScript("ControlFocus", StringBuilder.ToString)
End If
End Sub

If you call this sub each time a control posts back and use it to set focus
on the next control you should be all set. Of course this only solves the
problem you're having if the client is running javascript, but most should
be.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dusty Hackney" <Du**********@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
Hello,

I am doing web programming in VB ASP.NET. I have a group of fields that
the
user can tab through in order and fill in info in each of the fields.
Some
of the fields have code attached that runs when the value is changed in
that
field. However, the problem is that when postback occurs to run this
code,
it messes up the tab order for the user because, upon postsback, it starts
over and the first field in the list is where the tab starts again instead
of
letting the user continue to continue tabbing down the list from where
they
currently are. How can I get around this battle between postback and
taborder?

Thanks,
Dusty Hackney


Jan 11 '06 #3
Dusty,

You posted at the right time! :-)

Did this take care of things for you?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dusty Hackney" <Du**********@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Thanks for the quick response.
"S. Justin Gengo" wrote:
Dusty,

Use a javascript to set focus on the field. A startup script such as
this:

Private Sub SetFocus(ByVal webControl As
System.Web.UI.WebControls.WebControl)
If Not page.IsStartupScriptRegistered("ControlFocus") Then
Dim StringBuilder As New System.Text.StringBuilder
With StringBuilder
..Append("<script language=""javascript"">" & vbCrLf)
..Append(vbTab & "<!--" & vbCrLf)
..Append(vbTab & vbTab & "document.getElementById('" &
webControl.ClientID &
"').focus();" & vbCrLf)
..Append(vbTab & "//-->" & vbCrLf)
..Append("</script>" & vbCrLf)
End With
page.RegisterStartupScript("ControlFocus", StringBuilder.ToString)
End If
End Sub

If you call this sub each time a control posts back and use it to set
focus
on the next control you should be all set. Of course this only solves the
problem you're having if the client is running javascript, but most
should
be.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dusty Hackney" <Du**********@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
> Hello,
>
> I am doing web programming in VB ASP.NET. I have a group of fields
> that
> the
> user can tab through in order and fill in info in each of the fields.
> Some
> of the fields have code attached that runs when the value is changed in
> that
> field. However, the problem is that when postback occurs to run this
> code,
> it messes up the tab order for the user because, upon postsback, it
> starts
> over and the first field in the list is where the tab starts again
> instead
> of
> letting the user continue to continue tabbing down the list from where
> they
> currently are. How can I get around this battle between postback and
> taborder?
>
> Thanks,
> Dusty Hackney
>


Jan 11 '06 #4
Yes, it worked great. Thank you very much!
"S. Justin Gengo [MCP]" wrote:
Dusty,

You posted at the right time! :-)

Did this take care of things for you?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dusty Hackney" <Du**********@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
Thanks for the quick response.
"S. Justin Gengo" wrote:
Dusty,

Use a javascript to set focus on the field. A startup script such as
this:

Private Sub SetFocus(ByVal webControl As
System.Web.UI.WebControls.WebControl)
If Not page.IsStartupScriptRegistered("ControlFocus") Then
Dim StringBuilder As New System.Text.StringBuilder
With StringBuilder
..Append("<script language=""javascript"">" & vbCrLf)
..Append(vbTab & "<!--" & vbCrLf)
..Append(vbTab & vbTab & "document.getElementById('" &
webControl.ClientID &
"').focus();" & vbCrLf)
..Append(vbTab & "//-->" & vbCrLf)
..Append("</script>" & vbCrLf)
End With
page.RegisterStartupScript("ControlFocus", StringBuilder.ToString)
End If
End Sub

If you call this sub each time a control posts back and use it to set
focus
on the next control you should be all set. Of course this only solves the
problem you're having if the client is running javascript, but most
should
be.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Dusty Hackney" <Du**********@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com...
> Hello,
>
> I am doing web programming in VB ASP.NET. I have a group of fields
> that
> the
> user can tab through in order and fill in info in each of the fields.
> Some
> of the fields have code attached that runs when the value is changed in
> that
> field. However, the problem is that when postback occurs to run this
> code,
> it messes up the tab order for the user because, upon postsback, it
> starts
> over and the first field in the list is where the tab starts again
> instead
> of
> letting the user continue to continue tabbing down the list from where
> they
> currently are. How can I get around this battle between postback and
> taborder?
>
> Thanks,
> Dusty Hackney
>


Jan 12 '06 #5

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

Similar topics

2
by: Duwayne | last post by:
I am having lots of trouble with one of my user controls (ascx) not automatically loading postback data. An image on the aspx page starts the postback and the parent has no problem loading it's own...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
3
by: Alex D. | last post by:
Hi. I need to use a linkbutton to open a new window (it has to be a linkbutton to match the look and feel of a link). In order to do that I use the OnClientClick property and insert some...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
3
by: teo | last post by:
Mozilla error on postback and validation ----------- A Button causes a Listbox to desappear. If no item has been selected on the Listbox, all is OK. If one or more items are selected,
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...
2
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application....
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
9
by: 200dogz | last post by:
Hi guys, I want to have a button which opens up a new window when pressed. <asp:Button ID="Button1" runat="server" Text="Open new window" /> ... Button1.Attributes.Add("OnClick",
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.