如何在加载页面时从底部开始滚动

时间:2014-12-30 15:53:39

标签: c# jquery css asp.net ajax

您好我正在使用asp.net/c#进行社交网络服务,我在发送消息方面遇到的问题很少。

当我开始发送邮件滚动display like this时。当我按下发送消息时,它首先显示旧消息并scroll is top,但我想要更新的消息,这意味着我的页面加载页面应首先显示新消息

我的aspx代码

<div style=" overflow-y:auto; height:368px; margin-top: -50px; border-top-style: groove; border-right-style: groove; border-left-style: groove; width: 602px; margin-left: 0px;" >      
              <asp:Repeater runat="server" ID="Repeater1" >
 <ItemTemplate>




     <div style="border-top: thin none #BBCEB3; border-bottom: thin none #BBCEB3; padding: 10px;  width: 548px; margin-top: -10px; right: 10px; left: 10px; border-left-width: thin; margin-left: 15px; background-color: #fffff0; border-left-color: #BBCEB3; border-right-color: #BBCEB3; border-top-style: groove; border-bottom-style: groove;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <br />
                    <div style="width: 58px; height: 40px">
                    <asp:Image ID="Image2" runat="server" Height="59px" ImageAlign="Top" ImageUrl='<%#Eval("SProfilePic") %> ' Width="55px" />
                        </div>
                    <div style="width: 307px;  margin-left: 65px; margin-top: -60px">
                        <asp:Label ID="Label6" runat="server" Font-Bold="True" Font-Names="Arial" ForeColor="#000066"><%#Eval("SenderName") %> </asp:Label>
                    </div>
                    <div id="status" style=" width: 461px; margin-left: 78px; margin-top: 11px;">&nbsp;<asp:Label ID="Label7" runat="server" Font-Italic="False" ForeColor="Black" Font-Size="Medium"><%#Eval("Messages") %> </asp:Label>
                    </div>
                    &nbsp;<div style="margin-left: 400px; background-color: #C0C0C0;">
                        <asp:Label ID="Label11" runat="server"  Text="" Font-Size="Small"><%#Eval("Time") %> </asp:Label>
                    </div>
                </div>




 </ItemTemplate>

2 个答案:

答案 0 :(得分:1)

将服务器控制器放在那里,例如:

<asp:Button ID="BtnOutside" runat="server" Text="Random" style="margin-left:-999px;" />

然后使用

Page.SetFocus(Me.BtnOutside.ClientID);

要获得焦点,因为负边距,客户端看不到该按钮。这应该将滚动条推到底部。

答案 1 :(得分:0)

将其放置在您想要重点关注的代码中-您可以使用此

在同一代码集中多次更改了“ ID”


<asp:Button ID="FocusBottom" runat="server" Text="Random" style="margin-left:-999px;"

在事件中(单击按钮即可)。

Page.SetFocus(FocusBottom);

将(#######)更改为您要呼叫的“ ID”

相关问题