WebPart 上的用户控制、回发/视图状态问题
我正在使用 Sharepoint WebPart 来加载 UserControl,该控件有一个按钮可以对回发进行一些处理。我遇到了一个问题:当我第一次单击按钮时,数据加载了! IsPosback 丢失,但是当我再次单击该按钮时不会发生这种情况。我认为我的问题在这里解释:Sharepoint Lifecycle,但我还没有找到解决方法。
任何帮助将不胜感激。
其他信息: 我在 WebPart 的 OnLoad 事件上使用 EnsureChildControls,并在 CreateChildControls 上加载 UserControl。
I'm using a Sharepoint WebPart to load a UserControl which has a button that does some processing on PostBack. I got a problem: when I click the button for the first time, the data loaded on ! IsPosback gets lost, but this does not occur when I click the button again. I think my problem is explained here: Sharepoint Lifecycle, but I haven't been able to find a workaround.
Any help would be really appreciated.
Additional Info:
I'm using EnsureChildControls on the WebPart's OnLoad event, and loading the UserControl on CreateChildControls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够通过以编程方式为用户控件指定 ID 来解决此问题。
例如:
更多信息在这里: http://bytes.com/topic/asp-net/answers/314816-dynamically-loaded-control-event-only-reached-2nd-postback
I was able to fix this by programatically specifying an ID to the User Control.
E.g.:
More info here: http://bytes.com/topic/asp-net/answers/314816-dynamically-loaded-control-event-only-reached-2nd-postback