I have a panel control to which i add image controls from code behind.
Panel1.Controls.Add(new Image { ImageUrl = String.Format("img/{0}.gif", x) });
However when i try to access the new image control to modify certain attributes, i get a literal control instead.
ie:
Panel1.Controls[0].Width=new Unit(10, UnitType.Pixel);
results in... "Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.Image'"
Why?? Please help.