Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请告诉我如何维护占位符的状态。我有一个占位符,我在其中动态添加了许多图像控件,但是当我的页面刷新时,占位符中的所有控件都会从中删除。占位符的 enableViewstate 设置为 true.. 请告诉我如何维护其状态..
ViewState 注册发生在页面生命周期中的 Init 事件之后。
如果您在 Init 之后添加动态图像,则它们不会注册为 ViewState 的一部分。如果您在Page_Init.
Page_Init
我认为您需要在 Page_PreInt() 事件中添加控件
您必须在每次页面加载时添加动态控件。控件不存储在 ViewState 中,只有控件状态和不发布数据的控件的数据。