Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hello experts,
I have more then ten list items in a checkboxlist (autopost back set to true for checkboxlist), If i check any listitem 2nd/3rd/4th list item focus is set back to first list item in the checkbox list. Is there any solution that focus stays at the checked item?
Thanks

here is code
C#
string value = string.Empty;
        string result = Request.Form["__EVENTTARGET"];
        string[] checkedBox = result.Split('$'); 
        int index = int.Parse(checkedBox[checkedBox.Length - 1]);
        if (chk_Bhid.Items[index].Selected)
        {
            value = chk_Bhid.Items[index].Value;           
        }
Posted
Updated 27-May-14 23:31pm
v2
Comments
Snesh Prajapati 28-May-14 5:17am    
Can you post your code here?
j snooze 28-May-14 17:45pm    
Do you have to postback on every checkbox click?
ErBhati 29-May-14 1:50am    
yes

1 solution

I have found Solution myself
JavaScript
<script type="text/javascript">
             var xPos, yPos;
             var prm = Sys.WebForms.PageRequestManager.getInstance();
             function BeginRequestHandler(sender, args) {
                 if ($get('<%=Div1.ClientID%>') != null) {
                     xPos = $get('<%=Div1.ClientID%>').scrollLeft;
                     yPos = $get('<%=Div1.ClientID%>').scrollTop;
                 }
             }
             function EndRequestHandler(sender, args) {
                 if ($get('<%=Div1.ClientID%>') != null) {
                     xPos = $get('<%=Div1.ClientID%>').scrollLeft = xPos;
                     yPos = $get('<%=Div1.ClientID%>').scrollTop = yPos;
                 }
             }
             prm.add_beginRequest(BeginRequestHandler);
             prm.add_endRequest(EndRequestHandler);
       </script>

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900