Repost : Protecting a textbox from input

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi all,

I have a gridview with bound controls and some column templates. One of
these column templates is a textbox which is used for running totals. I
don't want the user to edit this so I merely set the enabled property to
false. The problem I'm having is that when the page posts back to the server
then back to the client again, the viewstate is gone and it's initialazed to
0.

How can I keep the viewstate and yet prevent the user from editing the
values client-side?

Regards
John.
 
First, you could just make is a label rather then a textbox.

Second, you need to ensure that the control gets recreated sometime during
the Init event because the viewstate loads sometime between the Init and
Load.
 
have you tried using the clientside onfocus event, you could probably
setfocus to another screen area should the texbox recieve focus whihc should
still allow the value to be updated. Alternatively, you could always use a
label.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
Back
Top