Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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".
Posted 2-Aug-11 9:50am
Edited 2-Aug-11 10:32am
v5
Comments
AspDotNetDev at 3-Aug-11 17:19pm
   
Have you figured this out? I'm curious what could cause this.
   
Not yet... :/

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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>
 
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)?
  Permalink  
Comments
   
Well, I tried creating a very simple web page with a textbox in it, and set it to read only, and did not experience the problem. It's only the web site I';m actually working on.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 400
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 245
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 2 Aug 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100