只读文本框不是真的 [英] Readonly TextBox Isn't Really

查看:79
本文介绍了只读文本框不是真的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGrid,可以在其中编辑行.在EditItemTemplate中,其中一列具有TextBox和几个验证器.文本框中有数据.

当我尝试将文本框设置为只读时,我仍然可以单击控件并获得一个光标,并且当我按下baskcspace键(插入符号位于现有文本的末尾)时,应用程序崩溃,并且在同时使浏览器中的后退和前进按钮完全无效.恢复的唯一方法是关闭浏览器并重新启动调试器.

有谁知道为什么会这样吗?

注意:

0)我尝试禁用验证器,但这对行为没有任何影响.

1)如果禁用该控件,则它不会崩溃(也不允许我在该字段中键入内容).

2)我在Google上找不到任何东西-我不知所措.

编辑=============

我崩溃时遇到的错误是网页已过期".

I have a DataGrid where rows can be edited. Inside the EditItemTemplate, one of the columns has a TextBox and a couple of validators. There is data in the textbox.

When I tried to make the textbox read-only, I could still click in the control and get a cursor, and when I hit the baskcspace key (with the caret at the end of the existing text), the app crashes, and at the same time renders bothe the back and forward buttons in the browser completely useless. The only way to recover is to shut the browser down and restart the debugger.

Does anyone know why this might be happening?

NOTES:

0) I tried disabling the validators, and that didn''t have any impact on the behavior.

1) If I disable the control, it doesn''t crash (and doesn''t let me type in the field).

2) I couldn''t find anything on google - I''m at a loss.

EDIT =============

The error I get when it crashes is "Web page Expired".

推荐答案

我无法使用以下代码重现您的问题:
I could not reproduce your issue using this code:
<%@ Page Language="vb" AutoEventWireup="false" %>
<script runat="server">
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim animals As New List(Of Animal)
    animals.Add(New Animal With {.AnimalName = "JSOP"})
    animals.Add(New Animal With {.AnimalName = "Unicorn"})
    dgSample.EditItemIndex = 0
    dgSample.DataSource = animals
    dgSample.DataBind()
  End Sub
  Public Class Animal
    Public Property AnimalName As String
  End Class
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test ReadOnly</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:DataGrid runat="server" ID="dgSample" AutoGenerateColumns="false">
        <Columns>
          <asp:TemplateColumn HeaderText="Animal Name">
            <ItemTemplate>
              Viewing:
              <asp:TextBox runat="server" ReadOnly="true"

                Text='<%# DataBinder.Eval(Container.DataItem, "AnimalName")%>' />
            </ItemTemplate>
            <EditItemTemplate>
              Editing:
              <asp:TextBox runat="server" ReadOnly="true"

                Text='<%# DataBinder.Eval(Container.DataItem, "AnimalName")%>' />
            </EditItemTemplate>
          </asp:TemplateColumn>
        </Columns>
      </asp:DataGrid>
    </div>
    </form>
</body>
</html>



你使用的是什么浏览器?也许当您单击BACKSPACE时,您是否导航回到上一页(在这种常见情况下,您的网页已过期")?完成回发(例如,按ENTER键并激活页面上的默认按钮后)并尝试刷新页面时,您也可能会获得网页已过期".当您改用DELETE键时,是否会发生此问题?可能有一些JavaScript正在检测BACKSPACE键并导致浏览器导航到先前的URL吗?其他需要检查的内容:您确定在EditItemTemplate中将ReadOnly设置为"true"(只是要仔细检查),并且将AutoPostBack设置为"true"(这可能会引起一些问题)吗?



What browser are you using? Perhaps when you click BACKSPACE, you are navigating back to a previous page (that is a common scenario in which you''d get "web page expired")? You can also get "web page expired" when you have done a postback (e.g., after pressing ENTER and activating the default button on the page) and you try to refresh the page. Does the issue occur when you use the DELETE key instead? Could there be some JavaScript that is detecting the BACKSPACE key and causing the browser to navigate to the previous URL? Some other things to check: are you sure ReadOnly is set to "true" in the EditItemTemplate (just to double check) and do you have AutoPostBack set to "true" (that could cause some issues)?


这篇关于只读文本框不是真的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆