473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

determine if textbox is cleared

I have a textbox were users can enter data, then they can delete it all and enter in new data again and click submit. Is there a way to determine if the user deleted the text they entered in? I'm storing the data in a Varailble for further use and if they delete the text my varialble is keeping the old data entered plus adding the new data, I only want the new data they enter.

text = "Sue, Dave, Tom"

the user deletes "Sue, Dave, Tom"

and then enters "Greg, Chuck, Michelle"

so I only want to use "Greg, Chuck, Michelle", is there a way to determine if the firstnames entered got deleted?

Aug 13 '07 #1
6 1652
Is suggest adding a hidden field, which will act as a "dirty" flag.
Set its value through JavaScript in the client side onchange event of the textbox.

Then, read the hidden field's value in the server side code.

--

Riki
"Mike" <Mi**@community.nospam.comwrote in message news:uW**************@TK2MSFTNGP04.phx.gbl...
I have a textbox were users can enter data, then they can delete it all and enter in new data again and click submit. Is there a way to determine if the user deleted the text they entered in? I'm storing the data in a Varailble for further use and if they delete the text my varialble is keeping the old data entered plus adding the new data, I only want the new data they enter.

text = "Sue, Dave, Tom"

the user deletes "Sue, Dave, Tom"

and then enters "Greg, Chuck, Michelle"

so I only want to use "Greg, Chuck, Michelle", is there a way to determine if the firstnames entered got deleted?

Aug 13 '07 #2
I'm not sure how that would work. I'm doing something like that now so when they add the name it stays in state.

"Riki" <ri**@dontnagme.comwrote in message news:uA**************@TK2MSFTNGP02.phx.gbl...
Is suggest adding a hidden field, which will act as a "dirty" flag.
Set its value through JavaScript in the client side onchange event of the textbox.

Then, read the hidden field's value in the server side code.

--

Riki
"Mike" <Mi**@community.nospam.comwrote in message news:uW**************@TK2MSFTNGP04.phx.gbl...
I have a textbox were users can enter data, then they can delete it all and enter in new data again and click submit. Is there a way to determine if the user deleted the text they entered in? I'm storing the data in a Varailble for further use and if they delete the text my varialble is keeping the old data entered plus adding the new data, I only want the new data they enter.

text = "Sue, Dave, Tom"

the user deletes "Sue, Dave, Tom"

and then enters "Greg, Chuck, Michelle"

so I only want to use "Greg, Chuck, Michelle", is there a way to determine if the firstnames entered got deleted?

Aug 13 '07 #3
You can use the IndexOf property on a variable to see what the position is, of one string, inside another
if the IndexOf property is larger that zero- then it hasn't cleared

David Wier
http://aspnet101.com
http://iWritePro.com

"Mike" <Mi**@community.nospam.comwrote in message news:uW**************@TK2MSFTNGP04.phx.gbl...
I have a textbox were users can enter data, then they can delete it all and enter in new data again and click submit. Is there a way to determine if the user deleted the text they entered in? I'm storing the data in a Varailble for further use and if they delete the text my varialble is keeping the old data entered plus adding the new data, I only want the new data they enter.

text = "Sue, Dave, Tom"

the user deletes "Sue, Dave, Tom"

and then enters "Greg, Chuck, Michelle"

so I only want to use "Greg, Chuck, Michelle", is there a way to determine if the firstnames entered got deleted?

Aug 13 '07 #4
On Aug 13, 9:02 am, "Mike" <M...@community.nospam.comwrote:
I have a textbox were users can enter data, then they can delete it all and enter in new data again and click submit. Is there a way to determine if the user deleted the text they entered in? I'm storing the data in a Varailble for further use and if they delete the text my varialble is keeping the old data entered plus adding the new data, I only want the new data they enter.

text = "Sue, Dave, Tom"

the user deletes "Sue, Dave, Tom"

and then enters "Greg, Chuck, Michelle"

so I only want to use "Greg, Chuck, Michelle", is there a way to determine if the firstnames entered got deleted?
I am not sure if I am understanding the question correctly.. but
anyways I will give my input :-)

Do you want to do this check on client site or server site? On server
site it will be it will be easy since you have stored old values in
variable so just check if new text is part of old saved string.
Also your old string will be wiped out during the postback if you
don't save it in viewstate.
... something like
in Page Load do this..
this.ViewState["oldString"] = "Sue, Dave, Tom";

In Submit button etc
if (!oldString.Contains(UserTextBox.Text))
{
this.ViewState["oldString"] +=UserTextBox.Text;
}

On Client site you will need javascript

Aug 13 '07 #5
On Aug 13, 10:18 am, "newsgrou...@gmail.com" <newsgrou...@gmail.com>
wrote:
On Aug 13, 9:02 am, "Mike" <M...@community.nospam.comwrote:
I have a textbox were users can enter data, then they can delete it all and enter in new data again and click submit. Is there a way to determine if the user deleted the text they entered in? I'm storing the data in a Varailble for further use and if they delete the text my varialble is keeping the old data entered plus adding the new data, I only want the new data they enter.
text = "Sue, Dave, Tom"
the user deletes "Sue, Dave, Tom"
and then enters "Greg, Chuck, Michelle"
so I only want to use "Greg, Chuck, Michelle", is there a way to determine if the firstnames entered got deleted?

I am not sure if I am understanding the question correctly.. but
anyways I will give my input :-)

Do you want to do this check on client site or server site? On server
site it will be it will be easy since you have stored old values in
variable so just check if new text is part of old saved string.
Also your old string will be wiped out during the postback if you
don't save it in viewstate.
.. something like
in Page Load do this..
this.ViewState["oldString"] = "Sue, Dave, Tom";
typo in old code corrected below.
In Submit button etc
if (!this.ViewState["oldString"] .Contains(UserTextBox.Text))
{
this.ViewState["oldString"] +=UserTextBox.Text;

}

On Client site you will need javascript

Aug 13 '07 #6
I need it on the client side but I need to clear out the server side
variable if the textbox is deleted (empty)
<ne*********@gmail.comwrote in message
news:11**********************@x40g2000prg.googlegr oups.com...
On Aug 13, 9:02 am, "Mike" <M...@community.nospam.comwrote:
>I have a textbox were users can enter data, then they can delete it all
and enter in new data again and click submit. Is there a way to determine
if the user deleted the text they entered in? I'm storing the data in a
Varailble for further use and if they delete the text my varialble is
keeping the old data entered plus adding the new data, I only want the
new data they enter.

text = "Sue, Dave, Tom"

the user deletes "Sue, Dave, Tom"

and then enters "Greg, Chuck, Michelle"

so I only want to use "Greg, Chuck, Michelle", is there a way to
determine if the firstnames entered got deleted?

I am not sure if I am understanding the question correctly.. but
anyways I will give my input :-)

Do you want to do this check on client site or server site? On server
site it will be it will be easy since you have stored old values in
variable so just check if new text is part of old saved string.
Also your old string will be wiped out during the postback if you
don't save it in viewstate.
.. something like
in Page Load do this..
this.ViewState["oldString"] = "Sue, Dave, Tom";

In Submit button etc
if (!oldString.Contains(UserTextBox.Text))
{
this.ViewState["oldString"] +=UserTextBox.Text;
}

On Client site you will need javascript

Aug 13 '07 #7

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

Similar topics

1
by: Gill Smith | last post by:
when the page is loaded I am using onload event at the client side and setting the focus on the control(TextBox). However when the user clicks on Clear ImageButton, I am clearing all the text boxes...
5
by: JollyK | last post by:
Hello all, I have always been having this issue and wondering what the solution is. When I set the enableviewstate property to false for a textbox, the textbox always retains its value after a...
2
by: Tim Zych | last post by:
I am trying to follow the instructions from http://authors.aspalliance.com/das/tutorial/fileupload.aspx to upload a file. The webform contains 2 buttons and a textbox. Browse for a file, click...
6
by: Tom McLaughlin | last post by:
How can I determine the numbers of lines of text that are visible in a textbox? Tom
6
by: Andrea V.F. | last post by:
How can I determine the control under the mouse cursor when a user muves the mouse?? For example if the user moves the cursor over a textbox i would receive the name of that textbox without using...
7
by: Doru Roman | last post by:
Hi, What is the fastest way to evaluate manually the result in this case: int a, b, c; a = 255; b = 122; c = a & b; The only way I know is transforming each number into the binary value...
1
by: sureshreddy | last post by:
Hi friends, I am working on a project on asp.net using c#. I had a problem in the textbox. I have a default value on the textbox as 'keywords'. when i click on the textbox the 'keywords' should be...
3
by: murugavelmsc | last post by:
Hi, In asp.net, I have a form of user name and Password textbox control and i set in the username textboxes as "Enter Username" and in passord textbox as Enter Password" whenever i focus into...
8
by: pinkfloydfan | last post by:
Hi there I have a form with two TextBoxes each of which has an _Enter event. In each case the _Enter event binds to the same Excel SheetSelectionChange event. What I want to know is: within...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
1
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...
0
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...
0
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,...
1
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...
0
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...

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.