c# - 当 UpdatePanel 触发时,IE8 光标跳到文本区域的末尾

标签 c# asp.net internet-explorer-8 updatepanel textarea

我在这样的页面上有一个 UpdatePanel 和一个文本区域:

<asp:Timer runat="server" ID="Timer" Interval="1000" OnTick="Tick" />
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
    <ContentTemplate>
        <asp:Label ID="Label" runat="server" />          
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger controlid="Timer" eventname="Tick" />
    </Triggers>
</asp:UpdatePanel>

<asp:TextBox runat="server" Width="600" Height="400" TextMode="MultiLine" />

// Codebehind
protected void Tick(object sender, EventArgs e) {
    Label.Text = DateTime.Now.ToString();
}

每当 UpdatePanel 计时器触发时,textarea 中的光标移动到文本的末尾。如果您尝试将任何文本添加到文本区域的中间,就会变得非常困难,因为光标一直跳到末尾。这发生在IE8中。所有其他浏览器都非常乐意让您在文本的中间键入而不会出现问题。

知道为什么在 IE 中会发生这种情况以及如何阻止它吗?

最佳答案

我相信 IE8 有一个已知的文本区域错误。

尝试将最小宽度和最大宽度设置为相同的值。

只是为了确定,如果您使用兼容模式,是否会出现此错误?

textarea {
  width: 700px;
  min-width: 100%;
  max-width: 100%;
}

您可能还想设置一个固定的像素 height 属性。

关于c# - 当 UpdatePanel 触发时,IE8 光标跳到文本区域的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5859062/

相关文章:

c# - 在非控制情况下使用 SqlDataSource

javascript - 如何处理 IE 8 中缺少 JavaScript Object.bind() 方法

css - 正斜杠/in CSS 边框半径语法

c# - 注释单元测试c#

c# - 如何告诉 Fluent NHibernate 不要映射类属性

c# - 将 html 组件添加到页面的 AJAX 最佳实践

html - IE8 并排 DIVS 正在堆叠

c# - 撤销功能无法检查证书的撤销

c# - 将克隆的 SPView 添加到列表

c# - 在 OnItemDataBound 期间获取中继器中的项目数