2014-12-30 93 views
1

嗨我正在使用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> 

回答

0

把服務器控制器存在例如這樣的:

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

然後用

Page.SetFocus(Me.BtnOutside.ClientID); 

將焦點集中到客戶端不可見的那個按鈕上,因爲負邊距。這應該將滾動條推到底部。

+0

感謝朋友,我應該在哪裏放置這個page.setfocus代碼?在文件後面的代碼? –

+0

是把它放在那裏。我猜你的發送按鈕確實發回?所以當你點擊發送按鈕並且該網站正在發送回 –

+0

時,請關注BtnOutSide什麼是我的關鍵字?它不會退出 –

相關問題