Q:

What is the difference between Image Attribute and ImageURL in ASP.NET?

I have googled and crawled SO about this but couldn't find any reliable info.
What is the any difference between changing the photo source of an image in ASP.NET by
myImage.Attributes["src"] = "/files/image1.jpg";

and
myImage.ImageUrl = "~/files/image1.jpg";

A:

The ImageUrl attribute has the advantage that you can use the ~ character, which stands for the application root. 
myImage.ImageUrl = "~/files/image1.jpg";

This is useful in cases where the root of the application is in a subfolder and you don't need to hard code the folder's name in your code. 

