TextBox TextChanged Event

S

sunilthk

Hi All,
I want to know how the TextBox control knows that it's data has been
changed, since it is able to detect changes and fires TextChange event
if the data in the TextBox has been changed. I know that TextBox class
implements IPostBackDataHandler interface which defines a method
LoadPostData(string postDataKey,NameValueCollection postCollection)
the postCollection keeps the posted data for each web control. How
ASP.NET fills this postCollection objects, i thought that ASP.NET uses
view state to get posted values, but i set EnableViewState property of
the text box=false then also the text changed event is firing.
In other words in order to detect whether the TextBox's data has been
changed
you must know the old value and new value, so how ASP.NET knows the
last posted value even if View State is disabled for the TextBox.
Please let me know how this happens.
Thanks
Sunil
 
A

Alessandro Zifiglio

hi Sunil,
with viewstate disabled, the textbox does not know if the text has changed
or not. It just fires the ontextchanged event regardless, whether the text
changed or not. With viewstate enabled it compares old and new value and
then fires the textchanged event only if the text has changed.
Regards,
Alessandro Zifiglio
 
S

sunilthk

Hi Alessandro,
You are right, i've checked that (as you said) if view state is
disabled TextChanged event fires if text is changed or not.
Thanks alot for clearing my doubt. So it means ASP.NET uses ViewState
to get posted values ?
Thanks
Sunil
 
A

Alessandro Zifiglio

yes Sunil, asp.net stores the old value in viewstate, while getting the new
value via http post through the form object collection.
regards,
Alessandro.
 

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,787
Messages
2,569,630
Members
45,334
Latest member
66Zeinab9

Latest Threads

Top