HotSpotCollection.Item[Int32] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會取得集合 HotSpot 中指定索引 HotSpotCollection 物件的參考。
public:
property System::Web::UI::WebControls::HotSpot ^ default[int] { System::Web::UI::WebControls::HotSpot ^ get(int index); };
public System.Web.UI.WebControls.HotSpot this[int index] { get; }
member this.Item(int) : System.Web.UI.WebControls.HotSpot
Default Public ReadOnly Property Item(index As Integer) As HotSpot
參數
屬性值
集合 HotSpot 中 HotSpotCollection 指定索引的物件。
範例
以下程式碼範例示範如何利用該Item[]屬性直接存取HotSpot控制項ImageMap集合中包含的HotSpotCollection物件,並在頁面上以標籤顯示每個物件屬性的AlternateText值。 為了讓這個範例正常運作,你必須為該屬性提供自己的影像 ImageUrl ,並適當更新影像的路徑,讓應用程式能夠找到它。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" language="C#">
void Page_Load(object sender, EventArgs e)
{
// Use the indexer to access each object in the
// HotSpotCollection and display the value of
// its AlternateText property to the user.
for (int i = 0; i <= Shop.HotSpots.Count - 1; i++)
{
Label1.Text += "<br />" + Shop.HotSpots[i].AlternateText + "<br />";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>HotSpotCollection.Item Property Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>HotSpotCollection.Item Property Example</h3>
<h4>Shopping Choices:</h4>
<asp:imagemap id="Shop"
imageurl="Images/ShopChoice.jpg"
alternatetext="Shopping choices"
runat="Server">
<asp:circlehotspot
navigateurl="http://www.tailspintoys.com"
x="145"
y="120"
radius="75"
hotspotmode="Navigate"
alternatetext="Shop for toys">
</asp:circlehotspot>
<asp:circlehotspot
navigateurl="http://www.cohowinery.com"
x="145"
y="290"
radius="75"
hotspotmode="Navigate"
alternatetext="Shop for wine">
</asp:circlehotspot>
</asp:imagemap>
<asp:label id="Label1"
runat="Server">
</asp:label>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" language="vb">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Use the Item property to access each object in the
' HotSpotCollection and display the value of
' its AlternateText property to the user.
For i As Integer = 0 To Shop.HotSpots.Count - 1
Label1.Text += "<br />" + Shop.HotSpots.Item(i).AlternateText + "<br />"
Next
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>HotSpotCollection.Item Property Example</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>HotSpotCollection.Item Property Example</h3>
<h4>Shopping Choices:</h4>
<asp:imagemap id="Shop"
imageurl="Images/ShopChoice.jpg"
alternatetext="Shopping choices"
runat="Server">
<asp:circlehotspot
navigateurl="http://www.tailspintoys.com"
x="145"
y="120"
radius="75"
hotspotmode="Navigate"
alternatetext="Shop for toys">
</asp:circlehotspot>
<asp:circlehotspot
navigateurl="http://www.cohowinery.com"
x="145"
y="290"
radius="75"
hotspotmode="Navigate"
alternatetext="Shop for wine">
</asp:circlehotspot>
</asp:imagemap>
<asp:label id="Label1"
runat="Server">
</asp:label>
</form>
</body>
</html>
備註
使用此索引器使用陣列符號,存取 HotSpot 集合中指定的索引物件。 索引器允許你直接修改或替換集合中的物件 HotSpot 。