Ideally Image control is used to place an image on the page. When it is rendered on the page, it is implemented through <img /> HTML tag.
Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc.
are implemented through style properites of <img>.
Following are some important properties that are very useful.
| ImageUrl |
Url of image location.
|
| AlternetText |
Appears if image not loaded properly or if image is missing in the specified location.
|
| Tooltip |
Text message Appearing on mouse over the image
|
| ImageAlign |
Used to align the Text beside image.
|
|
DEMO : Label
|
Show Source Code
|
If image is not loaded, AlternetText appears instead of the image
If image loaded, on mouse over tooltip appears
This is DotNet Funda logo.
|
|
// If image is not loaded, AlternetText appears instead of the image
<asp:Image ID="Image2" runat="Server" ImageUrl="~/images/DotNetFunda.gif" AlternateText="DotNetFunda Logo"
ImageAlign="textTop" ToolTip="Go to DotNetFunda Home page" />
<hr style="size:1px;" />
// If image loaded, on mouse over tooltip appears
<asp:Image ID="Image3" runat="Server" ImageUrl="~/images/DotNetLogo.gif" AlternateText="DotNetFunda Logo"
ImageAlign="Middle" ToolTip="DotNetFunda Logo tooltip." /> This is DotNet Funda logo.
|
There is one important but rarely used property of Label control is
AssociatedControlID that is used to associate a Label with a particular Control. Like in this example,
Click anywhere in the page except "Write something into the TextBox" in the demo box then click "Write something into the TextBox" and notice that Cursor is placed in the TextBox.