I have one <asp:Image ID="imgBanner1" runat="server"/> control in my aspx page, then in code behind I have this test code:
Image img = new Image();
img.ImageUrl = "~/img/home/home1.jpg";
//...
imgBanner1 = img; //<--
then when I refresh the page, the src value of the <img> is blank and the picture doesn't appear. I tried to put the snippet in Page_Load, Page_Init, Page_PreInit events but still doesn't work. How can I solve this? I need to asign some custom controls of other clases in my pages... thanks for your answers!.
Edit: It works if I do this:
imgBanner1.ImageUrl = img.ImageUrl;
//...