访问动态生成的控件内的控件 [英] Accessing controls inside a dynamically generated control

查看:64
本文介绍了访问动态生成的控件内的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行时在另一个控件的Page_Load方法中创建各种控件的实例.然后将动态生成的控件添加到占位符.

I'm creating instances of various controls at runtime in the Page_Load method of another control. The dynamically generated controls are then added to a Placeholder.

从动态生成的控件内部(在其自己的Page_Load方法中),我试图设置各种Literal的值,但它们均为null.

From inside the dynamically generated controls (in their own Page_Load method) I am trying to set the values of various Literals, but they are all null.

任何人都可以阐明为什么我无法访问这些文字吗?

Can anyone shed some light on why I can't access these Literals?

谢谢瑞安

推荐答案

已排序.需要使用LoadControl()方法.

Sorted. Need to use the LoadControl() method..

我正在尝试创建控件的实例.

I was trying to created an instace of the control instead.

这篇关于访问动态生成的控件内的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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