0

我的情况如下所示:我有 x 轴可滚动 div,其中包含显示页数的按钮。此 div 放置在负责在我的网站上显示新闻的用户控件内的数据列表中。

这是这个 div 和带有页码的数据列表的代码。

<div style="width:430px; overflow:auto; overflow-y:hidden; -ms-overflow-y:hidden; vertical-align:top; position:relative; top:-1px; ">
            <asp:DataList ID="dlPaging" runat="server" OnItemCommand="dlPaging_ItemCommand" RepeatDirection="Horizontal" 
                OnItemDataBound="dlPaging_ItemDataBound">
                <ItemTemplate>
                    <asp:Button ID="lnkbtnPaging" class="pagebutton" runat="server" CommandArgument='<%# Eval("PageIndex") %>'
                        CommandName="lnkbtnPaging" Text='<%# Eval("PageText") %>' CausesValidation="False" />
                </ItemTemplate>
            </asp:DataList>
            </div>

回发后如何保持这个div的x轴位置?我尝试了几种技巧,javascript,但我无法弄清楚。

4

2 回答 2

0

有什么理由不使用 UpdatePanel?

于 2011-10-30T07:31:29.810 回答
0
<div id="divDtPaging" runat="server" visible="true" style="width: 50%; overflow: scroll; text-align: center">
                            <asp:DataList runat="server" ID="dtPaging" OnItemCommand="dtPaging_ItemCommand"
                                OnItemDataBound="dtPaging_ItemDataBound" RepeatDirection="Horizontal"
                                SeparatorStyle-Wrap="true" Style="height: auto">
                                <ItemTemplate>
                                    <asp:LinkButton runat="server" ID="lnkbtnPaging" Text="PageText" CommandArgument="PageIndex" Style="padding-right: 5px">                                    
                                    </asp:LinkButton>
                                </ItemTemplate>
                            </asp:DataList>
                        </div>    
<asp:HiddenField id="hdnScrollPos" runat="server"/>

            <script type="text/javascript">
                function BeginRequestHandler(sender, args)
                {
                    document.getElementById('<%=hdnScrollPos.ClientID %>').value = document.getElementById('<%=divDtPaging.ClientID %>').scrollLeft;
                }
                function EndRequestHandler(sender, args) {
                    document.getElementById('<%=divDtPaging.ClientID %>').scrollLeft = document.getElementById('<%=hdnScrollPos.ClientID %>').value;
                }

                if (window.Sys && Sys.WebForms && Sys.WebForms.PageRequestManager) {
                    var prm = Sys.WebForms.PageRequestManager.getInstance()
                    prm.add_beginRequest(BeginRequestHandler);
                    prm.add_endRequest(EndRequestHandler);
                }

        </script>
于 2014-04-18T12:49:11.753 回答