473,698 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost : Protecting a textbox from input

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.


Nov 19 '05 #1
2 1096
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.

"John" <a@b.com> wrote in message
news:u1******** ******@TK2MSFTN GP10.phx.gbl...
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.

Nov 19 '05 #2
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

"John" <a@b.com> wrote in message
news:u1******** ******@TK2MSFTN GP10.phx.gbl...
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.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1363
by: andrewcw | last post by:
I have 2 frames - one with button and another with a grid How do I get a reference to the controls on the other webform ? From the one frame I can 'see the webform' fo the other frame, bit not the controls. A simple code snippet would help. MSDN subscriber - but I dont think its linking correctly. Thanks -- Andrew
0
2044
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows the available information based on the second combo box selection. But if I change my mind and select a different item in the second box, after the third box has been populated, the third box still retains the information that was previously...
2
2569
by: Alex Shirley | last post by:
HI I'm trying to iterate through all the textboxes on a webpage and trim them for spaces. i.e. If a user enters " hello world " we correct it to "hello world" So far I've come up with this:
9
2060
by: Darrel | last post by:
I'm learning a bit about the SWL injection issues and want to write a shared class that I can call from anywhere in my project to 'sanitize' any incoming text from textfields before sending to the DB. Is it enough to simply escape single quotes as two single quotes? Ie, replace ' with ''? Or should I also be checking for things like brackets, parenthesis and SQL command words (INSERT, UPDATE, DELETE, etc.)? And...maybe a dumb question,...
0
1665
by: Ken Powers | last post by:
Hello everyone, Sorry about the repost, my second VB.NET App is done with the exception of this error. I'm getting a strange error when I try to bind a combo box to a Dataset. Here's my code! Private Sub Get_Data() Try Dim sqlcmd = New SqlCommand("Select * from Utility order by
8
1343
by: Peter Proost | last post by:
Hi, this is my (simplified) situation: I have got 3 forms and one usercontrol: their names are: container (startup object),myform,another, mycontrol contair has got IsMdiContainer set to true, a mainmenu with a menuitem,
2
1693
by: Pipo | last post by:
Nobody knows how to get the values provided in the client can be read in the user-control? If have made a Web Custom Control with 2 textboxes and 1 dropdownlist. The user fills in my control (the textboxes and the dropdownlist) and lots more stuff on the page. When the user wants to save the page he'll click the save button. The server gets the postback but I can read out the filled in controls (in my control). The textboxes text = ""...
1
1110
by: D-Someone | last post by:
I am re-posting this message as originially it did not get a single response.. Any ideas? -------------- I am trying to come up with a good design for a web service that has some user logic and business processes involved. Here a small sample of the process flow: --- Client Get's User Input for field 1...
1
2452
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name and its rate should come in the next two cells...it should take from the data base... it's my code........ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <%@ page import="java.sql.*"...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.