1) User selecting an item in DropDownList is considered to be postback data, and for that reason DropDownList implements IPostbackDataHandler.
a) But why isn’t user moving ( in Calendar control ) to another month also considered a postback data? Thus, why does Calendar implement IPostbackEventHandler and not IPostbackDataHandler?
2)
a) I assume that controls implementing IPostbackEventHandler instead of IPostbackDataHandler never receive postback data?
b) If control implements IPostbackDataHandler, then control’s postback event will be fired each time its data changed, even if that control didn’t caused a postback
But if control implements IPostbackEventHandler, then only time that control’s postback event will be raised is if that control also triggered a postback?
IPostBackEventHandler
and IPostBackDataHandler
explain their purpose in the documentation, but they fail to make the distinction clear:
IPostBackEventHandler
is used for triggering events that are not dependent on data, but on a user's action. For example, the Calendar
control can trigger an event for when a date is clicked. This event is dependent on a user's actions, not the data the user entered.IPostBackDataHandler
is used for triggering events that are dependent on data in the control. For example, a TextBox
has an OnTextChanged
event, which should only be triggered if the text in the TextBox
changes.To add, controls which implement IPostbackDataHandler does not rely on the view state for retaining data across postbacks.
Edit: But all controls depend on view state to retain visibility
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With