如何在autopostback中保持列表框中的滚动条 [英] how to maintain scroll bar in listbox on autopostback

查看:83
本文介绍了如何在autopostback中保持列表框中的滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii,

我有一个带有autopostback的列表框。现在,每当发生autopostback时,滚动就会回到顶部,我想将滚动条保持为最后选择的项目。



谢谢

hii,
i am having a listbox with autopostback on. Now, whenever autopostback occurs scroll goes back to top, i want to maintain the scroll bar to the last item selected.

Thanks

推荐答案

有三种方法将属性应用于网页。



您可以通过编程方式设置它



There are three ways of applying the property to a web page.

You can set it programmatically

Page.MaintainScrollPositionOnPostBack = True



在页面声明中




In the page declaration

<%@ Page MaintainScrollPositionOnPostback="true" %>



或者在web.configs< system.web>中部分。




Or in the web.configs <system.web> section.

<pages maintainScrollPositionOnPostBack="true" />





查看此链接 -

维护列表框的滚动位置 [ ^ ]






设置列表框的高度和宽度,并将流设置为滚动,如下所示。

Hi,

set the height and width of the list box and set over flow as scroll as below.
<asp:listbox id="lstBox" runat="server" height="50px" width="100px" style="overflow:scroll;" xmlns:asp="#unknown">
   </asp:listbox>





这会将列表框的滚动位置保持在上一个选定位置。



MaintainScrollPositionOnPostback =true这是可选的,这个与列表框滚动条位置无关。这是针对整体页面滚动位置。你可以更好地设置它,这样在回发后不需要再向下滚动到那个位置。



希望它有所帮助。



this will maintain the scroll position of the list box to the previous selected position.

MaintainScrollPositionOnPostback="true" this is optional, this got nothing to do with list box scroll bar position. this is for overall page scroll position. better you can set this, so that no need to scroll down again to that position after post back.

hope it helps.


这篇关于如何在autopostback中保持列表框中的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆