HtmlImage Class
Assembly: System.Web (in system.web.dll)
Use this control to display an image on a Web page. The HtmlImage control can be programmatically manipulated to change the image displayed, the image size, and the alignment of the image relative to other page elements.
For a list of initial property values for an instance of HtmlImage, see the HtmlImage constructor.
The following code example demonstrates how to programmatically modify the properties of an HtmlImage control when an HtmlButton is clicked.
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void Image1_Click(object sender, EventArgs e) { Image1.Src="Image1.jpg"; Image1.Height=226; Image1.Width=500; Image1.Border=5; Image1.Align="center"; Image1.Alt="Image 1"; } void Image2_Click(object sender, EventArgs e) { Image1.Src="Image2.jpg"; Image1.Height=480; Image1.Width=640; Image1.Border=7; Image1.Align="left"; Image1.Alt="Image 2"; } void Image3_Click(object sender, EventArgs e) { Image1.Src="Image3.jpg"; Image1.Height=413; Image1.Width=631; Image1.Border=3; Image1.Align="right"; Image1.Alt="Image 3"; } </script> </head> <body> <form runat="server"> <h3>HtmlImage Example</h3> <center> <button id="Button1" OnServerClick="Image1_Click" runat="server"> Image 1 </button> <button id="Button2" OnServerClick="Image2_Click" runat="server"> Image 2 </button> <button id="Button3" OnServerClick="Image3_Click" runat="server"> Image 3 </button> </center> <br><br> <img id ="Image1" Src="Image1.jpg" Width="500" Height="226" Alt="Image 1" Border="5" Align="center" runat=server/> Enter the caption for this image here. </form> </body> </html>
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Web.UI.Control
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.HtmlControls.HtmlImage
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.