ASP.NET控件生命周期 - 加载视图状态后(ASP.NET Control Life Cycle - After Load View State)
我正在创建一个自定义控件,我需要处理一些逻辑AFTER
LoadViewState
(可能会或可能不会调用, 具体取决于控件是否可见 )和BEFORELoadPostBack
(可能会也可能不会调用, 具体取决于控件是否是可见或不可见 )。控制生命周期中有什么东西可以容纳这个吗?
我需要这个,因为我想在视图状态未加载时进行一些处理。 我不想在init中执行它,因为我会在那里执行它,然后可能必须在加载视图状态时再次执行它。
因此,我需要能够在未加载视图状态时运行代码(也就是在未调用LoadViewState时) 和控件生命周期中的相同位置 (在
Init
之后,在LoadPostData
之前)I am creating a custom control and I need to handle some logic AFTER
LoadViewState
(which may or may not be called depending on if the control was visible or not) and BEFORELoadPostBack
(which may or may not be called depending on if the control was visible or not).Is there anything in the control lifecycle that will accommodate this?.
I need this because I want to do some processing if the view state WAS NOT loaded. I don't want to do it in init because I would do it there, then potentially have to do it again when the view state is loaded.
So I need to be able to run code when the view state is not loaded (a.k.a when LoadViewState is not called) AND AT THE SAME PLACE in the life-cycle of the control (after
Init
, beforeLoadPostData
)
原文:https://stackoverflow.com/questions/3504254