Repost : Protecting a textbox from input

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.
 
P

Peter Rilling

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.
 
J

John Timney \(ASP.NET MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top