This documentation is archived and is not being maintained.

HtmlInputImage::Src Property

Gets or sets the location of the image file.

Namespace:  System.Web.UI.HtmlControls
Assembly:  System.Web (in System.Web.dll)

public:
property String^ Src {
	String^ get ();
	void set (String^ value);
}
<asp:HtmlInputImage Src="String" />

Property Value

Type: System::String
The location of the image file. The default value is an empty string ("").

Use the Src property to specify the location of the image to display in the HtmlInputImage control. If the image is not available, the text specified in the Alt property is displayed.

You can use a relative or absolute URL. A relative URL relates the location of the image to the location of the Web page without specifying a complete path on the server. The path is relative to the location of the Web page. This makes it easier to move the entire site to another directory on the server without updating the path to the image in code. You can use the relative path " ~/ " to refer to the current virtual directory where the page is located. For example, the value of Src for <input type="image" runat="server" src="~/abc/d.gif"> on a page in the "XspTest" virtual directory is <input type="image" src="/XspText/abc/d.gif">. An absolute URL provides the complete path. Therefore, moving the site to another directory requires that you update the code.

The following code example demonstrates how to use the Src property to specify the path to an image displayed in the HtmlInputImage control.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: