|
|
|
start date: Mon, 13 Aug 2007 09:02:56 -0400,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Mike
|
|
2
Riki
|
|
3
Mike
|
|
4
David Wier
|
|
5
unknown
|
|
6
unknown
|
|
7
Mike
|
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?
Date:Mon, 13 Aug 2007 09:02:56 -0400
Author:
|
Re: determine if textbox is cleared
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" wrote in message news:uW93Epa3HHA.5316@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?
Date:Mon, 13 Aug 2007 15:19:56 +0200
Author:
|
Re: determine if textbox is cleared
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" wrote in message news:uArMkya3HHA.5424@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" wrote in message news:uW93Epa3HHA.5316@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?
Date:Mon, 13 Aug 2007 09:40:29 -0400
Author:
|
Re: determine if textbox is cleared
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" wrote in message news:uW93Epa3HHA.5316@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?
Date:Mon, 13 Aug 2007 09:06:08 -0500
Author:
|
Re: determine if textbox is cleared
On Aug 13, 9:02 am, "Mike" wrote:
> 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
Date:Mon, 13 Aug 2007 14:18:46 -0000
Author:
|
Re: determine if textbox is cleared
On Aug 13, 10:18 am, "newsgrou...@gmail.com"
wrote:
> On Aug 13, 9:02 am, "Mike" wrote:
>
> > 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
Date:Mon, 13 Aug 2007 14:23:37 -0000
Author:
|
Re: determine if textbox is cleared
I need it on the client side but I need to clear out the server side
variable if the textbox is deleted (empty)
wrote in message
news:1187014726.402418.112840@x40g2000prg.googlegroups.com...
> On Aug 13, 9:02 am, "Mike" wrote:
>> 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
>
Date:Mon, 13 Aug 2007 10:34:53 -0400
Author:
|
|
|