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

Use <img> tags.

switch (intTypeID)
                {
                    case 1:
                        strNewsImage = "<img  src='images/news_general.gif' alt='' />";
                        break;
                    ....
                }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.