LoadViewState没有解雇我的用户控件 [英] LoadViewState not fired on my user control

查看:193
本文介绍了LoadViewState没有解雇我的用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有嵌套在一个中继器的用户控件。
我里面的用户控件我有另一个中继和我有一个面板。

I have a user control nested in a repeater. Inside my user control I have another repeater and in that I have a panel.

我想我的覆盖用户控件的LoadViewState事件,并动态地将控件添加到面板上。我想这样做的LoadViewState,使动态控制得到ViewState获取加载前加入,所以他们回发后保留它们的值。

I am trying to override the LoadViewState event of my user control and dynamically add controls to the panel. I want to do it in the LoadViewState so that the dynamic controls get added before the viewstate gets loaded, so they retain their values after post backs.

由于某种原因,用户控件(ASCX)的LoadViewState事件不会开火。是否有某种方式来迫使其火,还是有我可以用另一种方法?我已经排除了用户控制中继器数据绑定的事件,因为我需要它,即使数据绑定不发生工作,我不能做到这一点的中继项创建活动或者是因为孩子面板和内部HTML不存在然而。

For some reason the LoadViewState event on the user control (ascx) is not firing. Is there some way to force it to fire, or is there another method I could use? I have ruled out the user controls repeater databind event, because I need it to work even if data binding isn't happening and I can't do it on the repeaters item created event either because the child panel and inner html doesn't exist yet.

推荐答案

LoadViewState 不是添加子控件中的适当位置。对于用户控件内动态添加控件,你要看看<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.control.createchildcontrols.aspx\">CreateChildControls方法。

LoadViewState isn't the appropriate place for adding child controls. For dynamically adding controls within a user control, you'll want to look at the CreateChildControls method.

这不是发射了 LoadViewState 事件,因为你需要保存至少在一个值的ViewState 有事件火灾。

It's not firing a LoadViewState event because you need to save at least one value in the ViewState to have the event fire.

这篇关于LoadViewState没有解雇我的用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆