determine if textbox is cleared

M

Mike

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?
 
R

Riki

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
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?
 
M

Mike

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.

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
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?
 
D

David Wier

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

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?
 
N

newsgroupID

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
 
N

newsgroupID

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
 
M

Mike

I need it on the client side but I need to clear out the server side
variable if the textbox is deleted (empty)
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
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top