我刚学习Asp.Net& VB所以请温柔:-)代码是为我编写的,它显示了一个消息线程。它显示从顶部最旧到最近收到的回复框底部的消息。有没有什么办法可以添加到这个代码,使它在线程打开时自动向下滚动到线程的底部? 非常感谢任何帮助...
<div style="width:78%; float:right; overflow:auto; height:500px;" id="messagesWindow">
<asp:SqlDataSource ID="DSSelectMessages" runat="server"
ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
SelectCommand="SelectMessages" SelectCommandType="StoredProcedure">
<SelectParameters>
</SelectParameters>
</asp:SqlDataSource>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
<asp:HiddenField ID="hdnButtonFrom" runat="server" />
<div style="font-size:1.3em">
<asp:GridView ID="gdvMessages" runat="server" CssClass="mGrid" AutoGenerateColumns="False" DataKeyNames="messageID" ShowHeader="False" ShowFooter="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblContactFrom" runat="server" Text='<%# Eval("contactFrom") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblDateSent" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%# Eval("item") %>'></asp:Label>
<asp:HyperLink ID="hypItem" Visible="false" runat="server" CssClass="nyroModalMsg" NavigateUrl='<%# "~/Account/itemSold.aspx?br=messageList&fileID=" & Eval("fileID") %>'>Mark as Sold</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False" SortExpression="messageText">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("messageText") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine" Rows="5" Columns="32" MaxLength="2000"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="<br />Add Reply" CssClass="error" ValidationGroup="msgSubmit" ControlToValidate="txtMessage"></asp:RequiredFieldValidator>
<br />
<asp:Button ID="btnSend" runat="server" Text="Reply" onclick="btnSend_Click" ValidationGroup="msgSubmit" />
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("messageText") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
答案 0 :(得分:0)
尝试
Textbox1.SelectionStart = Textbox1.Text.Length - 1
Textbox1.ScrollToCaret()