【发布时间】:2015-06-08 08:11:25
【问题描述】:
我有一个可以在 pnRoom(面板)中动态添加的控件
ImageButton imgbtn = new ImageButton();
imgbtn = new ImageButton();
imgbtn.Height = 25;
imgbtn.CssClass = "bulb";
imgbtn.ID = i++;
pnRoom.Controls.Add(imgbtn);
我在找到控件时收到 null 值 imgbtn
protected void LoadBulb()
{
foreach (Control c in pnRoom.Controls)
{
ImageButton img = (ImageButton)c.FindControl("imgbtn");
img.ImageUrl = "~/path/images/bulb_yellow_32x32.png";
}
}
它总是返回null。我正在尝试,但没有运气。我需要你的帮助。谢谢!!!
对象引用未设置为对象的实例。
【问题讨论】:
标签: c# asp.net controls imagebutton findcontrol