Click here to Skip to main content
13,552,950 members
Rate this:
Please Sign up or sign in to vote.
See more:
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?


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 8:50am
Updated 2-Aug-11 9:32am
aspdotnetdev 3-Aug-11 17:19pm
Have you figured this out? I'm curious what could cause this.
Not yet... :/

1 solution

Rate this: bad
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
  End Sub
  Public Class Animal
    Public Property AnimalName As String
  End Class

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Test ReadOnly</title>
    <form id="form1" runat="server">
      <asp:DataGrid runat="server" ID="dgSample" AutoGenerateColumns="false">
          <asp:TemplateColumn HeaderText="Animal Name">
              <asp:TextBox runat="server" ReadOnly="true"

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

                Text='<%# DataBinder.Eval(Container.DataItem, "AnimalName")%>' />

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)?
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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03-2016 | 2.8.180515.1 | Last Updated 2 Aug 2011
Copyright © CodeProject, 1999-2018
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