title: How to change an image's ImageUrl attribute on page load with asp.net and C# in IE
body: <p>I have links on a homepage that may or may not have attachments associated with them.  If the links have attachments, then an icon will be placed next to the link.  The icon will only be there if the link has an attachment.</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          foreach (Image pic in imgAttachment)
              {
                   int type = ds.Current_Events[index].AttachmentID;
                   //ds is the dataset
  </code></pre>
  
  <p>The foreach loop is going through each of the "Current Event" pictures on the homepage then getting the type of attachment associated with each link aka the AtachmentID.  The AttachmentID can be a 0, 1, 2, or 3 which means no attachment, photo attached, video attached, or document attached repectively.  </p>
  
  <p>A switch statement is then used to change the ImageUrl attribute to the corresponding picture.</p>
  
  <pre><code>                 switch (type)
                       {
                              case 0:
                                  break;
                              case 1:
                                  pic.ImageUrl = "images/eventicons/Photo.jpg";
                                  //changed from just "Photo.jpg"
                                  break;
                              case 2:
                                  pic.ImageUrl = "images/eventicons/Video.jpg";
                                  //changed from just "Video.jpg"
                                  break;
                              case 3:
                                  pic.ImageUrl = "images/eventicons/Doc.jpg";
                                  //changed from just "Doc.jpg"
                                  break;
                              default:
                                  pic.Visible = false;
                                  break;
                        }
                    index++;
              }
      }
  </code></pre>
  
  <p>The image does not load in IE, however it does work for firefox.</p>
  
  <p>The following is the aspx front</p>
  
  <pre><code>&lt;div&gt;
    &lt;ul&gt;
     &lt;li&gt;
        &lt;asp:HyperLink ID="lblEvent1" runat="server"&gt;              
             &lt;img src="images/bar_blank.gif" /&gt;
        &lt;/asp:HyperLink&gt;
        &lt;asp:Image ID="Image1" runat="server" /&gt;
     &lt;/li&gt;
     &lt;li&gt;
        &lt;asp:HyperLink ID="lblEvent2" runat="server"&gt;
             &lt;img src="images/bar_blank.gif" /&gt;
        &lt;/asp:HyperLink&gt;
        &lt;asp:Image ID="Image2" runat="server" /&gt;
     &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>