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:
01421207
Views:
23
>>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.

The control level validations should not cause a postback unless controls explicitly set to do AutoPostBack. Validators (that come out of ASP.NET ) use JavaScript to show validation messages.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform