提供指定要顯示影像的控制項功能。
public class System.Web.UI.MobileControls.Image :
System.Web.UI.MobileControls.MobileControl,
System.Web.UI.IPostBackEventHandler
備註
Image 類別提供一種方式來根據裝置特性指定可供選擇的多個影像檔案。它不提供將影像從一組特性轉譯成另一組特性的服務,例如將彩色影像轉換成單色。在 Run Time,您可以根據裝置特性來對 Image 控制項指定可供選擇的多個影像檔案。或者,也可用宣告方式指定控制項的影像。
對於某些裝置,您可以在 ImageURL 屬性中使用 symbol: 前置詞當作 URL 的一部份,以指定內建的影像。如需詳細資訊,請參閱 Image 控制項的裝置特定章節。
範例
以下範例所示範的顯示影像會在執行 Page_Load 時設定其屬性。替代文字是出現在瀏覽器無法顯示影像,或找不到影像的情況下。
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="VB" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script language="vb" runat="server">
Sub Page_Load()
' Programmatically add an image.
Image1.ImageUrl = "MSImage.gif"
' Set the image properties programmatically.
Image1.AlternateText = "No image available"
Image1.Alignment = Alignment.Left
Image1.NavigateURL = "https://www.microsoft.com"
End Sub
</script>
<mobile:Form id="Form1" runat="server" >
<mobile:Image runat="server" id="Image1" />
</mobile:form>
[C#]
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="c#" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script language="c#" runat="server">
void Page_Load()
{
// Programmatically add an image.
Image1.ImageUrl = "MSImage.gif";
// Set the image properties programmatically.
Image1.AlternateText = "No image available";
Image1.Alignment = Alignment.Left;
Image1.NavigateURL = "https://www.microsoft.com";
}
</script>
<mobile:Form id="Form1" runat="server" >
<mobile:Image runat="server" id="Image1" />
</mobile:form>
需求
命名空間:System.Web.UI.MobileControls
**組件:**System.Web.Mobile