Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retaining focus after postback
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01421141
Message ID:
01421203
Views:
35
>>I'm tasked with helping a developer finish up a web page that collects information about an order and populates some SQL Server tables. ASPX with C#. I'm not a C# guy, but my main job here is to keep him on task, interface with the dept. that will need this, and validate the data design. At present, there are some issues with postbacks. He does a good bit of validation, mostly to ensure fields aren't blank, and posts back upon exit of a good many fields. One problem is retaining focus after postback. The user enters a value, presses tab, and a postback occurs. Instead of the focus moving to the next field, there seems to be no field with focus after the postback, which forces the user to click in the next field with the mouse. So instead of being able to tab to fields as expected, the user keeps having to use the mouse to get the focus to the appropriate field. This is not very desireable at all. Another issue is what fields cause a postback. An example would be a field that can be empty (zero), but if it's >0 another field needs to be populated. The postback occurs after the first field and an error message is displayed next to the second field saying it can't be empty, yet the user hasn't even had a chance to enter anything in that field. This is most likely a simple fix of where the validation originates from (the second field instead of the first), but the programmer seems to think this is hard to do or not doable. I may have to dig into C#, but some help here would be appreciated.
>>
>>Thanks,
>>
>>Russell Campbell
>
>If your form has an AJAX scriptmanager, then all you need is..
>
> Dim manager As ScriptManager = ScriptManager.GetCurrent(Page)
> manager.SetFocus(This.ControlID)

Alright, thanks. What I'm wondering about is maintaining where focus should be given that focus hasn't gotten to the next control, yet. I'm thinking that when the user tabs out of the control, the postback occurs, but you can't do something like save the ID of the control and restore it after postback, because then you'll never be able to get out of the control (at least if a change was made - it might not post back if no change is made, I don't know). Also, the user will be expecting to move to the next field. They don't want to end up in the same field. If you have to give the ControlID, then what happens if fields are rearranged? That will mess up the tab order. What if someone does a shift-tab and expects to go back to the prevous control, where they see they've made a mistake? This suggestion seems like it might do what we want, but could have its own issues. I'm not sure why we have to post back after exiting so many fields as we move through the form. Changing to validation at the page level instead of the control level may be one possible solution. Thanks again for the reply.
eCost.com continues to rip people off
Check their rating at ResellerRatings.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform