Retreiving old value from WebControls.TextBox with OnTextChanged

  • Thread starter Thread starter Mark Siffer
  • Start date Start date
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
 
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!)
 
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
 
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

Back
Top