0

Hi all, I am kinda new to the area so please bear with me :)

I want to dynamically display an image according to a certain variable obtained from an XML document and I did the following code where intTypeID is a variable whose value changes according to the nodes being read:

// Choose which image to show
                switch (intTypeID)
                {
                    case 1:
                        strNewsImage = "<asp:Image \"ID=imgGeneral\" runat=\"server\" ImageUrl=\"~/images/news_general.gif\" />";
                        break;
                    case 2:
                        strNewsImage = "<asp:Image \"ID=imgEvent\" runat=\"server\" ImageUrl=\"~/images/news_event.gif\" />";
                        break;
                    default:
                        strNewsImage = "<asp:Image \"ID=imgGeneral\" runat=\"server\" ImageUrl=\"~/images/news_general.gif\" />";
                        break;
                }

However the images are not displaying...any idea as to why? I am sure that the <asp:Image..> code is correct as when I copy it in the .aspx part it displays correctly. Can you please help me :)

Thanks
Darren

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

Use <img> tags.

switch (intTypeID)
                {
                    case 1:
                        strNewsImage = "<img  src='images/news_general.gif' alt='' />";
                        break;
                    ....
                }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.