ASP.NET Image Control

The Image control is used to display an image.

C# Code

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Drawing;
using System.Web.UI.WebControls;

namespace asptutorial
    public partial class blankpage : System.Web.UI.Page

        protected void Page_Load(object sender, EventArgs e)

            Image1.ImageUrl = "~/files/logo.png";
            Image1.ImageAlign = ImageAlign.Left;
            Image1.AlternateText = "Fastlearning logo";



   <asp:Image ID="Image1" runat="server" ImageUrl="~/files/logo.png" AlternateText="Fastlearning logo" ImageAlign="Left"/>


Property Description
AlternateText An alternate text for the image
DescriptionUrl The location to a detailed description for the image
GenerateEmptyAlternateText Specifies whether or not the control creates an empty string as an alternate text
ImageAlign Specifies the alignment of the image
ImageUrl The URL of the image to display for the link
runat Specifies that the control is a server control.  Must be set to "server"

ASP.NET Control Standard Properties

AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Visible
For a full description, go to Web Control Standard Attributes.

ASP.NET Web Control Standard Properties

AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, SkinID, Style, TabIndex, ToolTip, Width
For a full description, go to Web Control Standard Attributes.

Share this article on