I have an update panel that is triggered by a timers tick event. I have an issue that when users open a dropdown or have a textbox focused that when the timer ticks at its interval the controls lose focus. This is really annoying and I don't know how to
prevent this. Any ideas? My timer ticks ever 10 seconds and only updates the page if another user has updated some information in the database.
Thanks in advance!
Courage...
Remember to click “Mark as Answer” on the post(s) that help you...
yes its because when javascript updates some other elements then focus while be misplaced.
what you do is inside the function take the vairable and store the elementID of current focused element then at the end of the interval method execution set back the focus to the storedID element
to store the focused element loop throug input element and check whether its focused if then the store it or you may also implement focus event on all the input element and update the variable with the id
Thank you both for the responses. I understand that I could use JavaScript for setting the focus of a textbox but the issue I was having was with the drop down. When a user clicked a dropdown and the list of items drops down, if an update occurred
then the list of items would dissapear, the user would have to click the control again to get the list to appear. This was very annoying but I found a work around.
I put the area with the drop down and textboxes into a separate updatepanel and set the UpdateMode="Conditional" this allowed me to update that panel, only when necessary not when the other updatepanels updated.
I do appreciate the responses and again they would have worked if it was strictly for textboxes.
Courage...
Remember to click “Mark as Answer” on the post(s) that help you...
Marked as answer by link224444 on Jul 10, 2012 01:04 PM
link224444
Member
326 Points
129 Posts
Update Panel with Timer
Jul 09, 2012 02:09 PM|LINK
Hi Everyone,
I have an update panel that is triggered by a timers tick event. I have an issue that when users open a dropdown or have a textbox focused that when the timer ticks at its interval the controls lose focus. This is really annoying and I don't know how to prevent this. Any ideas? My timer ticks ever 10 seconds and only updates the page if another user has updated some information in the database.
Thanks in advance!
Remember to click “Mark as Answer” on the post(s) that help you...
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: Update Panel with Timer
Jul 09, 2012 02:30 PM|LINK
yes its because when javascript updates some other elements then focus while be misplaced.
what you do is inside the function take the vairable and store the elementID of current focused element then at the end of the interval method execution set back the focus to the storedID element
to store the focused element loop throug input element and check whether its focused if then the store it or you may also implement focus event on all the input element and update the variable with the id
link224444
Member
326 Points
129 Posts
Re: Update Panel with Timer
Jul 09, 2012 05:37 PM|LINK
This still won't prevent the dropdown from retraction when the updatepanel updates though. This does work for the textboxes though.
Remember to click “Mark as Answer” on the post(s) that help you...
chetan.sarod...
All-Star
65759 Points
11153 Posts
Re: Update Panel with Timer
Jul 10, 2012 03:29 AM|LINK
Whatever the dropdown or textbox is outside or inside of updatepanel, you can also use javascript to reset the focus on the textbox. It's ok.
Async request will lost the focus of the textbox on the page, you can use javascript to set the focus to the specific textbox.
http://forums.asp.net/t/1199709.aspx
http://vincexu.blogspot.com/2009/06/keep-textbox-focus-inside-updatepanel.html
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
link224444
Member
326 Points
129 Posts
Re: Update Panel with Timer
Jul 10, 2012 01:04 PM|LINK
Thank you both for the responses. I understand that I could use JavaScript for setting the focus of a textbox but the issue I was having was with the drop down. When a user clicked a dropdown and the list of items drops down, if an update occurred then the list of items would dissapear, the user would have to click the control again to get the list to appear. This was very annoying but I found a work around.
I put the area with the drop down and textboxes into a separate updatepanel and set the UpdateMode="Conditional" this allowed me to update that panel, only when necessary not when the other updatepanels updated.
I do appreciate the responses and again they would have worked if it was strictly for textboxes.
Remember to click “Mark as Answer” on the post(s) that help you...