Reputation: 6166
I have a ASP.NET user control which hosts a 'HtmlImage'. The src attribute is successfully set at run-time, but adding the rendered control to another container causes a loss of the src attribute.
The rendered control is stored in Session (I know this is not ideal). Then a redirect is done to another page which uses the control in Session.
Perhaps it's because the url is not encoded?
Code:
<img id="ctlImage" runat="server" style="border-style: none;" />
ctlImage.Src = String.Format("..\image.aspx?{0}", "...")
Upvotes: 0
Views: 406
Reputation: 2115
It could be because the attributes of HtmlControls (including HtmlImage) are stored in ViewState. It seems reasonable that ViewState wouldn't get sent along to the other page.
Instead of storing the control in Session, why not just store the generated html code? Much more lightweight.
Upvotes: 1
Reputation: 12795
Have you tried using an asp:Image control instead of a plain old img tag?
Upvotes: 1