我在这样的页面上有一个 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/