Retreiving old value from WebControls.TextBox with OnTextChanged

M

Mark Siffer

I would like to capture the previous value of a WebControl.TextBox in the
OnTextChanged event. I can't seem to find anything online about discovering
this value.

Thanks in advance
MS
 
K

Karl Seguin

I believe that it's lost. You'll need to store the value somewhere
yourself...

string value = "oldPassword"
txtPassword.Text = value;
ViewState.Add("originalPassword", value)


OnTextChange
string newValue = txtPassword.Text
string originalPassword = (string)ViewState["originalPassword"]
...
end


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
M

Mark Siffer

But it must be retrievable somewhere right? How else would the
OnTextChanged event get raised?


Karl Seguin said:
I believe that it's lost. You'll need to store the value somewhere
yourself...

string value = "oldPassword"
txtPassword.Text = value;
ViewState.Add("originalPassword", value)


OnTextChange
string newValue = txtPassword.Text
string originalPassword = (string)ViewState["originalPassword"]
...
end


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Mark Siffer said:
I would like to capture the previous value of a WebControl.TextBox in the
OnTextChanged event. I can't seem to find anything online about discovering
this value.

Thanks in advance
MS
 
K

Karl Seguin

The value is maintained in viewstate, but it's simply overwrites the Text
property on postback...i don't know of a good way to dig inside the
viewstate to get the value...you could certainly look at Denis Bauer's
Viewstate viewer and you might get some
hints...http://www.denisbauer.com/ASPNETControls.aspx

Karl



--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Mark Siffer said:
But it must be retrievable somewhere right? How else would the
OnTextChanged event get raised?


Karl Seguin said:
I believe that it's lost. You'll need to store the value somewhere
yourself...

string value = "oldPassword"
txtPassword.Text = value;
ViewState.Add("originalPassword", value)


OnTextChange
string newValue = txtPassword.Text
string originalPassword = (string)ViewState["originalPassword"]
...
end


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Mark Siffer said:
I would like to capture the previous value of a WebControl.TextBox in the
OnTextChanged event. I can't seem to find anything online about discovering
this value.

Thanks in advance
MS
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top