HotSpotCollection.Insert Method

Inserts a specified HotSpot object into the HotSpotCollection collection at the specified index location.

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

public void Insert(
	int index,
	HotSpot spot


Type: System.Int32

The array index at which to add the HotSpot object.

Type: System.Web.UI.WebControls.HotSpot

The HotSpot object to add to the collection.

The Insert method adds the specified HotSpot object to the collection at the specified index location. To append a HotSpot object to the end of the collection, use the Add method.

The following code example demonstrates how to programmatically add two CircleHotSpot objects to an ImageMap control. The HotSpots property is used to access the HotSpotCollection collection. The Add method adds Circle2 to the collection. The Insert method adds Circle1 to the collection at the first element, in front of Circle2. For this example to work correctly, you must supply your own image for the ImageUrl property and update the path to the image appropriately so that the application can locate it.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">
  void Page_Load (Object sender, EventArgs e)
    // Programmatically create a CircleHotSpot object.
    CircleHotSpot Circle2 = new CircleHotSpot();
    Circle2.HotSpotMode = HotSpotMode.Navigate;
    Circle2.NavigateUrl = "";
    Circle2.X = 145;
    Circle2.Y = 290;
    Circle2.Radius = 75;
    Circle2.AlternateText = "Shop for wine";    

    // Add Circle2 to the ImageMap's HotSpotCollection.

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

    // Insert Circle1 into the ImageMap's HotSpotCollection
    // at the first element in the array.    
    Shop.HotSpots.Insert(0, Circle1);


<html xmlns="" >
<head id="Head1" runat="server">
  <title>HotSpotCollection.Insert Example</title>
    <form id="Form1" runat="server">

      <h3>HotSpotCollection.Insert Example</h3>

      <h4>Shopping Choices:</h4>

      <asp:imagemap id="Shop"
        alternatetext="Shopping choices"


.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft