awright4911
New Member
I have a control with a listbox inside an updatepanel connected to a timer which is doing an autopostback with a scriptmanager on the main form. To keep the item selected throughout the postback I use the below javascript. I have researched this quite thoroughly and don't believe there is another way to keep the selecteditem selected between postbacks. However this solution seems to work quite well.My issue is that when I add a second control to the main form it won't work. I have tried moving the javascript into the main form however I cannot access the child controls from the main form using: \[code\]document.getElementById('<%=PositionsControl.FindControl("ListBox_Candidates").ClientID %>').selectedIndex\[/code\]I have also tried renaming the BeginRequestHandler and EndRequestHandler to unique names (to avoid conflicts when this script is on both control) and it will not work.Any help is greatly appreciated.\[code\]<script type="text/javascript"> var index var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_beginRequest(BeginRequestHandler); prm.add_endRequest(EndRequestHandler); function BeginRequestHandler(sender, args) { index = document.getElementById('<%=ListBox_Candidates.ClientID %>').selectedIndex; } function EndRequestHandler(sender, args) { $get('<%=ListBox_Candidates.ClientID %>').selectedIndex = index; }</script> \[/code\]