I have a control that add dynamically in pnRoom (panel)
ImageButton imgbtn = new ImageButton();
imgbtn = new ImageButton();
imgbtn.Height = 25;
imgbtn.CssClass = "bulb";
imgbtn.ID = i++;
pnRoom.Controls.Add(imgbtn);
And i'm received null value when finding control imgbtn
protected void LoadBulb()
{
foreach (Control c in pnRoom.Controls)
{
ImageButton img = (ImageButton)c.FindControl("imgbtn");
img.ImageUrl = "~/path/images/bulb_yellow_32x32.png";
}
}
It's allways return null. I'm try but no luck. i need your help. Thanks !!!
Object reference not set to an instance of an object.