PRB: ASP.NET fires Change events even if you do not change the control value (314809)
The information in this article applies to:
- Microsoft ASP.NET (included with the .NET Framework 1.1)
- Microsoft ASP.NET (included with the .NET Framework) 1.0
This article was previously published under Q314809 SYMPTOMS Under specific circumstances, ASP.NET fires the Change
event for an ASP.NET Web control even if you do not change the control.
CAUSE Some controls, such as the SelectedIndexChanged event in a DropDownList control or the TextChanged event in a TextBox control, rely on the registration of the Change event to use view
state. You encounter this problem when you create these controls dynamically
after the event is hooked up.
When ASP.NET renders the page to the
browser, the controls that are created dynamically do not have an associated
Change event. Because no event is present, ASP.NET does not save the view
state. This is called View State Optimization.
When the page is
posted back, and when the events are hooked up, ASP.NET expects view state but
finds that none exists. This difference fires the Change event even if the
control has not been changed. RESOLUTION Make sure that you hook up the Change event for dynamically
created controls before ASP.NET renders the page. This ensures that view state
for the control exists. STATUSThis
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 5/3/2004 |
---|
Keywords: | kbDataBinding kbEvent kbprb kbServerControls kbState kbWebForms KB314809 kbAudDeveloper |
---|
|