HotSpotCollection 类

定义

表示 ImageMap 控件内的 HotSpot 对象的集合。 此类不能被继承。

public ref class HotSpotCollection sealed : System::Web::UI::StateManagedCollection
public sealed class HotSpotCollection : System.Web.UI.StateManagedCollection
type HotSpotCollection = class
    inherit StateManagedCollection
Public NotInheritable Class HotSpotCollection
Inherits StateManagedCollection
继承
HotSpotCollection

示例

下面的代码示例演示如何以编程方式创建控件,以及如何向其添加两CircleHotSpotImageMap对象。 该HotSpots属性用于访问控件的HotSpotCollectionImageMap集合,并将对象添加到CircleHotSpot该集合。 若要使此示例正常工作,必须为属性提供自己的映像 ImageUrl ,并相应地更新映像的路径,以便应用程序能够找到它。

<%@ page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  void Page_Load (Object sender, EventArgs e)
  {
    // Programmatically create an ImageMap control.
    ImageMap Shop = new ImageMap();
    
    // Set properties on the ImageMap control.
    Shop.ImageUrl = "Images/ShopChoice.jpg";
    Shop.AlternateText = "Shopping choices";

    // Add the ImageMap control to the 
    // Controls collection of the page.
    Page.Controls.Add(Shop);

    // Programmatically create a CircleHotSpot object.
    CircleHotSpot Circle1 = new CircleHotSpot();
    Circle1.HotSpotMode = HotSpotMode.Navigate;
    Circle1.NavigateUrl = "http://www.tailspintoys.com";
    Circle1.X = 145;
    Circle1.Y = 120;
    Circle1.Radius = 75;
    Circle1.AlternateText = "Shop for toys";

    // Add Circle1 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle1);

    // Programmatically create a second CircleHotSpot object.
    CircleHotSpot Circle2 = new CircleHotSpot();
    Circle2.HotSpotMode = HotSpotMode.Navigate;
    Circle2.NavigateUrl = "http://www.cohowinery.com";
    Circle2.X = 145;
    Circle2.Y = 290;
    Circle2.Radius = 75;
    Circle2.AlternateText = "Shop for wine";

    // Add Circle2 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle2);
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap Class C# Constructor Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap Class C# Constructor Example</h3>
      
      <h4>Shopping Choices:</h4>
      
    </form>      
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    ' Programmatically create an ImageMap control.
    Dim Shop As New ImageMap
    Shop.ImageUrl = "Images/ShopChoice.jpg"
    Shop.AlternateText = "Shopping choices"
    
    ' Add the ImageMap control to the 
    ' Controls collection of the page.
    Page.Controls.Add(Shop)
    
    ' Programmatically create a CircleHotSpot object.
    Dim Circle1 As New CircleHotSpot
    Circle1.HotSpotMode = HotSpotMode.Navigate
    Circle1.NavigateUrl = "http://www.tailspintoys.com"
    Circle1.X = 145
    Circle1.Y = 120
    Circle1.Radius = 75
    Circle1.AlternateText = "Shop for toys"
    
    ' Add Circle1 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle1)
    
    ' Programmatically create a second CircleHotSpot object.
    Dim Circle2 As New CircleHotSpot
    Circle2.HotSpotMode = HotSpotMode.Navigate
    Circle2.NavigateUrl = "http://www.cohowinery.com"
    Circle2.X = 145
    Circle2.Y = 290
    Circle2.Radius = 75
    Circle2.AlternateText = "Shop for wine"

    
    ' Add Circle2 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle2)
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap Class VB Constructor Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap Class VB Constructor Example</h3>
      
      <h4>Shopping Choices:</h4>
      
    </form>      
  </body>
</html>

注解

HotSpotCollection 表示一个集合,该集合使 ImageMap 控件能够维护它包含的对象的列表 HotSpot

Add使用该方法将指定HotSpot对象添加到序号索引数组末尾的集合。 Insert使用该方法将对象添加到HotSpot集合中的指定索引位置。 Item[]使用索引器通过简单的数组表示法直接访问HotSpot集合中的对象。

Remove使用该方法从集合末尾删除HotSpot对象。 RemoveAt使用该方法从指定的索引位置删除HotSpot对象。

构造函数

HotSpotCollection()

初始化 HotSpotCollection 类的新实例。

属性

Count

获取 StateManagedCollection 集合中包含的元素的数量。

(继承自 StateManagedCollection)
Item[Int32]

获取 HotSpot 集合中位于指定索引位置的 HotSpotCollection 对象。

方法

Add(HotSpot)

将指定的 HotSpot 对象追加到 HotSpotCollection 集合的末尾。

Clear()

StateManagedCollection 集合中删除所有项。

(继承自 StateManagedCollection)
CopyTo(Array, Int32)

从特定的数组索引开始,将 StateManagedCollection 集合的元素复制到数组中。

(继承自 StateManagedCollection)
CreateKnownType(Int32)

在派生类中替代时,创建实现 IStateManager 的类的实例。 所创建对象的类型基于由 GetKnownTypes() 方法返回的集合的指定成员。

(继承自 StateManagedCollection)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回循环访问 StateManagedCollection 集合的迭代器。

(继承自 StateManagedCollection)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetKnownTypes()

在派生类中替代时,获取 StateManagedCollection 集合可以包含的 IStateManager 类型的数组。

(继承自 StateManagedCollection)
GetType()

获取当前实例的 Type

(继承自 Object)
Insert(Int32, HotSpot)

将指定的 HotSpot 对象插入到 HotSpotCollection 集合中的指定索引位置。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OnClear()

在派生类中替代时,在 Clear() 方法从集合中删除所有项之前执行附加工作。

(继承自 StateManagedCollection)
OnClearComplete()

在派生类中替代时,在 Clear() 方法完成从集合中删除所有项之后执行附加工作。

(继承自 StateManagedCollection)
OnInsert(Int32, Object)

在派生类中替代时,在 IList.Insert(Int32, Object)IList.Add(Object) 方法向集合中添加项之前执行附加工作。

(继承自 StateManagedCollection)
OnInsertComplete(Int32, Object)

在派生类中替代时,在 IList.Insert(Int32, Object)IList.Add(Object) 方法向集合中添加项之后执行附加工作。

(继承自 StateManagedCollection)
OnRemove(Int32, Object)

在派生类中替代时,在 IList.Remove(Object)IList.RemoveAt(Int32) 方法从集合中删除指定项之前执行附加工作。

(继承自 StateManagedCollection)
OnRemoveComplete(Int32, Object)

在派生类中替代时,在 IList.Remove(Object)IList.RemoveAt(Int32) 方法从集合中删除指定项之后执行附加工作。

(继承自 StateManagedCollection)
OnValidate(Object)

在派生类中替代时,验证 StateManagedCollection 集合的一个元素。

(继承自 StateManagedCollection)
Remove(HotSpot)

HotSpot 集合中移除指定的 HotSpotCollection 对象。

RemoveAt(Int32)

从集合中移除位于指定索引位置的 HotSpot 对象。

SetDirty()

强制将整个 StateManagedCollection 集合序列化为视图状态。

(继承自 StateManagedCollection)
SetDirtyObject(Object)

在派生类中替代时,指示集合包含的 object 将其全部状态记录到视图状态,而不是仅记录更改信息。

(继承自 StateManagedCollection)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

ICollection.Count

获取 StateManagedCollection 集合中包含的元素的数量。

(继承自 StateManagedCollection)
ICollection.IsSynchronized

获取指示 StateManagedCollection 集合是否已同步(线程安全)的值。 此方法在所有情况下均返回 false

(继承自 StateManagedCollection)
ICollection.SyncRoot

获取可用于同步对 StateManagedCollection 集合的访问的对象。 此方法在所有情况下均返回 null

(继承自 StateManagedCollection)
IEnumerable.GetEnumerator()

返回循环访问 StateManagedCollection 集合的迭代器。

(继承自 StateManagedCollection)
IList.Add(Object)

StateManagedCollection 集合中添加一个项。

(继承自 StateManagedCollection)
IList.Clear()

StateManagedCollection 集合中删除所有项。

(继承自 StateManagedCollection)
IList.Contains(Object)

确定 StateManagedCollection 集合中是否包含特定值。

(继承自 StateManagedCollection)
IList.IndexOf(Object)

确定 StateManagedCollection 集合中的指定项的索引。

(继承自 StateManagedCollection)
IList.Insert(Int32, Object)

将项在指定索引处插入 StateManagedCollection 集合中。

(继承自 StateManagedCollection)
IList.IsFixedSize

获取指示 StateManagedCollection 集合是否具有固定大小的值。 此方法在所有情况下均返回 false

(继承自 StateManagedCollection)
IList.IsReadOnly

获取指示 StateManagedCollection 集合是否为只读的值。

(继承自 StateManagedCollection)
IList.Item[Int32]

获取指定索引处的 IStateManager 元素。

(继承自 StateManagedCollection)
IList.Remove(Object)

StateManagedCollection 集合中删除指定对象的第一个匹配项。

(继承自 StateManagedCollection)
IList.RemoveAt(Int32)

删除指定索引处的 IStateManager 元素。

(继承自 StateManagedCollection)
IStateManager.IsTrackingViewState

获取指示 StateManagedCollection 集合是否保存对其视图状态的更改的值。

(继承自 StateManagedCollection)
IStateManager.LoadViewState(Object)

还原 StateManagedCollection 集合以及其包含的 IStateManager 项的以前保存的视图状态。

(继承自 StateManagedCollection)
IStateManager.SaveViewState()

保存自页回发到服务器后对 StateManagedCollection 集合和该集合包含的每个 IStateManager 对象所做的更改。

(继承自 StateManagedCollection)
IStateManager.TrackViewState()

使 StateManagedCollection 集合及其包含的每个 IStateManager 对象跟踪对它们的视图状态所做的更改,以使它们可以在相同页的请求之间得以保持。

(继承自 StateManagedCollection)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

适用于

另请参阅