I have links on the home page that may or may not have attachments associated with them. If the links have attachments, an icon will be placed next to the link. The icon will only be there if the link has an attachment.
protected void Page_Load(object sender, EventArgs e)
{
foreach (Image pic in imgAttachment)
{
int type = ds.Current_Events[index].AttachmentID;
The foreach loop goes through each of the Current Event images on the home page, then gets the type of binding associated with each link, for example, AtachmentID. AttachmentID can be 0, 1, 2 or 3, which means there is no attachment, no attachment, no attachment, video or attachment.
The switch statement is then used to change the ImageUrl attribute to the corresponding image.
switch (type)
{
case 0:
break;
case 1:
pic.ImageUrl = "images/eventicons/Photo.jpg";
break;
case 2:
pic.ImageUrl = "images/eventicons/Video.jpg";
break;
case 3:
pic.ImageUrl = "images/eventicons/Doc.jpg";
break;
default:
pic.Visible = false;
break;
}
index++;
}
}
The image does not load in IE, however it works for firefox.
aspx
<div>
<ul>
<li>
<asp:HyperLink ID="lblEvent1" runat="server">
<img src="images/bar_blank.gif" />
</asp:HyperLink>
<asp:Image ID="Image1" runat="server" />
</li>
<li>
<asp:HyperLink ID="lblEvent2" runat="server">
<img src="images/bar_blank.gif" />
</asp:HyperLink>
<asp:Image ID="Image2" runat="server" />
</li>
</ul>
</div>