更新面板的计时器和滚动条位置 [英] Timer and scrollbar position of update panel
本文介绍了更新面板的计时器和滚动条位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,我需要一些帮助.
当前,我有一个gridview,它将随着计时器更新,并且单击按钮时也会更新gridview.
所以现在,我目前在滚动updatepanel/gridview时遇到一个问题,我希望它保持在滚动条位置.但是,当我单击按钮时,我希望updatepanel/gridview返回到底部(已经有javascript).
提前谢谢!
Hello, I need some help.
Currently, I have a gridview that will update with the timer and also a button when clicked, will update the gridview.
So now, I am currently facing a problem regarding when scrolling the updatepanel/gridview, I would like it to remain at scrollbar position. But when I click on the button, I will like the updatepanel/gridview to return to bottom (already have the javascript).
Thanks in advance!
<div id="scrollChat" style="overflow: auto; width: 80%; height: 250px; margin-left: auto;
margin-right: auto;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="timer" runat="server" OnTick="timer_Tick" Interval="2000">
</asp:Timer>
<asp:UpdatePanel ID="upChat" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="gvChat" runat="server" Style="width: 100%;" Font-Names="Verdana"
AutoGenerateColumns="True" ShowHeader="False" GridLines="None">
<RowStyle Height="25" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<div id="chat" style="height: 1px;">
</div>
</div>
<div style="width: 100%; height: 100px; text-align: center; margin-removed 30px;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="tbMsg" Rows="3" Height="60px" Width="80%" TextMode="multiline" runat="server"
Style="margin-bottom: 15px;" Font-Names="Verdana" placeholder="Type your message here..."></asp:TextBox>
<br />
<asp:Button ID="btnSend" class="btn btn-primary btn-lg" runat="server" Text="Send"
OnClick="btnSend_Click" Width="200px" Font-Bold="true" Font-Names="Verdana" OnClientClick="btnSend_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br />
<br />
<script type="text/javascript">
Sys.Application.add_load(function () {
var t = document.getElementById('scrollChat');
t.scrollTop = t.scrollHeight;
});
</script>
推荐答案
只是想知道您是否已经尝试过在Page标记中添加MaintenanceScrollPositionOnPostback ="true".
Just wondering if you have already tried by adding MaintainScrollPositionOnPostback="true" in Page tag.
这篇关于更新面板的计时器和滚动条位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文