本文介绍了IPostbackEventHandler VS IPostbackDataHandler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)用户选择在一个项目的的DropDownList 的被认为是回发数据,并且为此原因的的DropDownList 的器具的 IPostbackDataHandler 的。

一)但为什么没有用户移动(在日历的控制),其他月份也被认为是一个回传数据?因此,为什么的日历的实施的 IPostbackEventHandler 的而不是 IPostbackDataHandler 的?


2)
一)我认为控制实施的 IPostbackEventHandler 的而不是 IPostbackDataHandler 的永远不会收到回传数据呢?


b)若控制工具的 IPostbackDataHandler 的,那么控件的回发事件将其数据更改时都会解雇,即使该控件没有引起回发

但是,如果控件实现的 IPostbackEventHandler 的,那么只有一次控件的回发事件将提出的是,如果该控件也引发了回传?

解决方案
  1. 的DropDownList VS日历事件接口:
    • 在下拉列表中选择被认为是数据。你会提交在下拉列表数据的信息(在大多数情况下)。
    • 更改对日历控件的选择被认为是一个事件,而不是提交数据的事件。它只是触发一个事件,使得code知道要改变控件的状态。
      这两者之间的区别是非常微妙的。
  2. 的文档<$c$c>IPostBackEventHandler和<$c$c>IPostBackDataHandler解释他们的目的在文档中,但他们未能做出明确的区分:
    • IPostBackEventHandler 终止用于触发不依赖于数据的事件,而是在用户的动作。例如,日历控件可以触发事件的日期被点击时进行。此事件是依赖于用户的操作,而不是用户输入的数据。
    • IPostBackDataHandler 用于触发那些依赖于控制数据的事件。例如,文本框有一个 OnTextChanged 事件,这应该只被触发,如果在<$ C $文C>文本框修改

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?

解决方案
  1. DropDownList vs Calendar event interfaces:
    • The selection in the drop down list is considered data. You would submit the information in the drop down list as data (in most cases).
    • Changing the selection on the Calendar control is considered an event, but not an event that submits data. It just triggers an event so that the code knows to change the control's state.
      The difference between these two is very subtle.
  2. The documentation for 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.

这篇关于IPostbackEventHandler VS IPostbackDataHandler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 13:55