Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何向下滚动到多行文本框';s的底线,Javascript';s scrollIntoView对此不起作用_C#_Javascript_Asp.net_Chatroom - Fatal编程技术网

C# 如何向下滚动到多行文本框';s的底线,Javascript';s scrollIntoView对此不起作用

C# 如何向下滚动到多行文本框';s的底线,Javascript';s scrollIntoView对此不起作用,c#,javascript,asp.net,chatroom,C#,Javascript,Asp.net,Chatroom,我正在尝试创建一个基本的视频和文本聊天网站。在聊天室页面中,我有一个flash视频和一个文本框(多行),显示发送到聊天室的所有消息,还有一个文本框供用户通过单击旁边的按钮键入和发送 <tr> <td> <asp:UpdatePanel ID="UpdtPnlMesajlar" runat="server" EnableViewState="true"> <ContentTemplate>

我正在尝试创建一个基本的视频和文本聊天网站。在聊天室页面中,我有一个flash视频和一个文本框(多行),显示发送到聊天室的所有消息,还有一个文本框供用户通过单击旁边的按钮键入和发送

<tr>
    <td>
         <asp:UpdatePanel ID="UpdtPnlMesajlar" runat="server" EnableViewState="true">
               <ContentTemplate>
                      <table>
                             <tr>
                                 <td>
                                     <asp:TextBox ID="TxtBxOdaMesajlari" 
                                      runat="server" ReadOnly="true"
                                      TextMode="MultiLine"
                                      Width="475" Height="100"  >
                                     </asp:TextBox>
                                 </td>
                             </tr>
                             <tr>
                                 <td>
                                     <asp:TextBox ID="TxtBxMesaj" runat="server" 
                                      Width="412"></asp:TextBox>
                                     <asp:Button ID="BttnGonder" runat="server"
                                      Text="Gönder" Width="55"
                                      OnClick="BttnGonder_click"/>
                                 </td>
                             </tr>
                      </table>
               </ContentTemplate>
            </asp:UpdatePanel>
       </td>
   </tr>
在出现大量消息后,可以看到滚动条
TxtBxOdaMesajlari
,但是无法看到新消息,因为
TxtBxOdaMesajlari
不会自动向下滑动/滚动。我搜索了这个示例,发现它使用Javascript的
scrollIntoView()
所以我决定使用它,但页面会闪烁,滚动根本不起作用。可能我使用了错误的控件,或者使用了错误的方法。 如果这很重要的话,我正在使用ASP.NET4.0

在aspx文件上

<script language="javascript" type="text/javascript">
    function buttonClicked() {
                $get("TxtBxOdaMesajlari").scrollIntoView("true");
            }
</script>

函数按钮单击(){
$get(“TxtBxOdaMesajlari”).scrollIntoView(“true”);
}

我使用的是
ScriptManager.RegisterStartupScript
,因为控件位于
UpdatePanel
中,正如用户建议的那样,并且工作正常:3742 of

scrollIntoView用于将文本框本身滚动到视图中,而不是其内容

要滚动到文本框的末尾,可以使用:

function buttonClicked() {
    var textBox = $get("TxtBxOdaMesajlari");
    textBox.scrollTop = textBox.scrollHeight;
}
function buttonClicked() {
    var textBox = $get("TxtBxOdaMesajlari");
    textBox.scrollTop = textBox.scrollHeight;
}