问题描述
我有我写的,并已添加到ASP.NET页面和功能就好了用户的控制。不过,我想从code中的那个自定义控件引用的属性后面,在Page_Load中,但不能,因为变量,这是访问,该实例为null。
I have a user control that I have written and have added to an ASP.NET page, and functions just fine. However, I am trying to reference a property in the that custom control from code behind, on Page_Load, but cannot, because the variable, which is accessible, for the instance is null.
这是正常的用户控件和Page_Load中?如果是这样,我怎么能做出控件实例的引用,以访问其公共属性?这是我需要做的页面呈现之前,为了初始化一些变量。
Is this normal for user controls and Page_Load? And if so, how can I make a reference to the control's instance in order to access its public properties? This is something I need to do before the page is rendered, in order to initialize some variables.
推荐答案
您也许可以访问从 Page_ preRender
事件用户控件。
You can probably access your user control from the Page_PreRender
event.
您可以找到有关asp.net的
You can find more documentation about the page life cycle in asp.net here.
这篇关于在页面code上的Page_Load引用时背后ASP.NET用户控件实例为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!