I am trying to maintain scroll position of checkbox list inside update panel.
I have used textbox , panel and popup extender to built my own control that extends textbox by using panel on click and checkbox list inside panel when mark check box item select in text box but its scroll position do not maintain ?
My code:
<div>
<asp:UpdatePanel ID="updatepanel1" runat="server" RenderMode="Inline">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:PopupControlExtender ID="TextBox1_PopupControlExtender" runat="server" DynamicServicePath=""
Enabled="True" ExtenderControlID="" TargetControlID="TextBox1" PopupControlID="Panel1"
OffsetY="22">
</asp:PopupControlExtender>
<asp:Panel ID="Panel1" runat="server" Height="116px" Width="145px" BorderStyle="Solid"
BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#CCCCCC"
Style="display:none ">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataTextField="holiday_name"
DataValueField="holiday_name" AutoPostBack="True" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged" >
</asp:CheckBoxList>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
I tried it by using this post,
Maintain Panel Scroll Position On Partial Postback ASP.NET
I used script like,
<script type="text/javascript">
var xpos, ypos;
var pra = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
alert("hello");
if ($get('<%=CheckBoxList1.ClientID%>') != null) {
xpos = $get('<%=CheckBoxList1.ClientID%>').scrollLeft;
ypos = $get('<%=CheckBoxList1.ClientID%>').scrollTop;
}
}
function EndRequestHandler(sender, args) {
if ($get('<%=CheckBoxList1.ClientID%>') != null) {
xpos = $get('<%=CheckBoxList1.ClientID%>').scrollLeft = xpos;
ypos = $get('<%=CheckBoxList1.ClientID%>').scrollTop = ypos;
}
}
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
</script>
...but this script not working fine it is not alerting "Hello" perhaps its not calling methods ??
Hoping for suggestions as I have been searching and trying to resolve this issue.
Thanks