473,385 Members | 1,531 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,385 software developers and data experts.

Taborder after postback

kpg
After an autopostback event the control that gets focus next
is not the one defined in the taborder, but the first control.

This makes sense becuase the page is reloaded, but of course this
is not the desired behaviour.

I have seen the use of a hidden field, which stores the name of the control
that should get focus next, being set in the autopostback event, then an
OnPageLoad javascript that sets the focus to it.

This works, but only for 'forward' tabs, and the next control has nothing
to do with the taborder but is set in code.

It seems like there should be a better solution to this problem.

Actually, it seems like the viewstate should handle this automatically.

Any ideas or solutions?

kpg
May 25 '06 #1
4 2105
"kpg" <no@way.com> wrote in message
news:Xn*******************************@207.46.248. 16...
It seems like there should be a better solution to this problem.
There doesn't need to be, as it's fully customisable server-side.
Actually, it seems like the viewstate should handle this automatically.
ViewState simply preserves values in form field either side of a postback
until / unless they are changed by that postback - no more, no less.
Any ideas or solutions?


You already know which of your client-side objects (button, dropdownlist,
hyperlink, checkbox etc) has caused the postback, and write server-side code
to be processed accordingly. Simply add the following to the end of the
server-side code as required:

ClientScript.RegisterStartupScript(this.GetType(), "focus",
"<script>document.getElementById('....').focus ();</script>");

Obviously, replace .... with the ID of the control that you want to receive
the focus.

N.B. this is v2 syntax, but v1.1 is almost identical.
May 25 '06 #2
kpg
As Mark Rae once said in microsoft.public.dotnet.framework.aspnet
ClientScript.RegisterStartupScript(this.GetType(), "focus",
"<script>document.getElementById('....').focus ();</script>");


Well, that is a more eloquent solution than the one I had
described and I thank you for it.

It does still leave the (albeit small) issue of the user
pressing a shift-tab on an autopostback field. In that
case it would still move forward in the tab order.

And not to dwell on this point to much, my comment about
the viewstate was to simply introduce the concept that
the page 'knows' where it would have set focus to before
the postback, and as such it could remember this bit of
information somewhere (the viewstate for lack of a better
place?) and automatically move the focus there when the page
is returned. Perhaps there are reasons why this can't be
done, it was just an intuitive thought I had.

But as it stands I'll use your suggestion.

Thanks.
kpg
May 25 '06 #3
"kpg" <no@way.com> wrote in message
news:Xn*******************************@207.46.248. 16...
It does still leave the (albeit small) issue of the user
pressing a shift-tab on an autopostback field. In that
case it would still move forward in the tab order.
Hmm - yeah, OK, I know what you mean but as you hint at, the likelihood of
this happening is fairly small. I've always been a great believer in the
80/20 rule for web development i.e. 20% of effort supplies 80% of usability,
and just how far you go to supplying the final 20% is really down to
time/budget/sanity...
And not to dwell on this point to much, my comment about
the viewstate was to simply introduce the concept that
the page 'knows' where it would have set focus to before
the postback, and as such it could remember this bit of
information somewhere (the viewstate for lack of a better
place?) and automatically move the focus there when the page
is returned. Perhaps there are reasons why this can't be
done, it was just an intuitive thought I had.


No, the ViewState really doesn't know this - that's not what it's for.

The ViewState's one and only purpose is to persist form values and page
variables across postbacks.

You as the programmer know what's supposed to happen next, so go to it -
that's your job! :-)
May 25 '06 #4
kpg
As Mark Rae once said in microsoft.public.dotnet.framework.aspnet
You as the programmer know what's supposed to happen next, so go to it
- that's your job! :-)


Point taken, but of course languages do indeed provide much of
what programmers used to do. Case in point - tab order. In
DOS programming (I know, I go way back) the programmer had to
specify all possible movements based on left, right, up, down,
tab, CR. Then in windows programming, tab order was introduced,
and the run time system handled movement. Well, all that spoiled
me, so with web programming (which I'm new to, can you tell?) I
see many areas where we are taking a step backwards.

Well, I've ridden this point well into the ground so I'll stop.

Thanks for your help.

kpg
May 26 '06 #5

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

Similar topics

2
by: kea | last post by:
I have a checkbox and a textbox in a continuous taborder on a form along with a bunch of other controls. The textbox is disabled. When I leave the checkbox I want to enable the textbox and move...
2
by: Walti | last post by:
Hi I stumbled over a strange problem in A2K concerning the Tab Order of 60 textboxes placed on a tab control: whenever I change the TabIndex of any one of these textboxes the other 59 change...
2
by: kea | last post by:
I have a checkbox and a textbox in a continuous taborder on a form along with a bunch of other controls. The textbox is disabled. When I leave the checkbox I want to enable the textbox and move...
2
by: Hans Kesting | last post by:
Hi, Navigating with "tab" and "shift-tab" between textbox and radiobutton has sometimes some strange results. Some example fields: - several textboxes (say: tb1, tb2) - some radiobuttons...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.