HotSpotCollection.Remove Method (HotSpot)


Removes the specified HotSpot object from the HotSpotCollection collection.

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

public void Remove(
	HotSpot spot


Type: System.Web.UI.WebControls.HotSpot

The HotSpot object to remove from the collection.

The Remove method removes the specified HotSpot object from the collection. To remove a HotSpot object from the collection at a specified index location, use the RemoveAt method.

To add new HotSpot objects to the collection, use the Add or the Insert method.

The following code example demonstrates how to programmatically add two CircleHotSpot objects to an ImageMap control. After the two CircleHotSpot objects are added to the HotSpotCollection collection, the Remove method is used to delete Circle1 from the collection. 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 Circle1 = new CircleHotSpot ();
    Circle1.HotSpotMode = HotSpotMode.Navigate;
    Circle1.NavigateUrl = "";
    Circle1.X = 145;
    Circle1.Y = 120;
    Circle1.Radius = 75;
    Circle1.AlternateText = "Shop for toys";

    // Programmatically create a second 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 the HotSpot objects to the ImageMap's 
    // HotSpotCollection.            
    Shop.HotSpots.Add (Circle1);
    Shop.HotSpots.Add (Circle2);

    // Use the Remove method to delete the Circle1 
    // object from the HotSpotCollection.
    Shop.HotSpots.Remove (Circle1);


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

      <h3>HotSpotCollection.Remove Example</h3>

      <h4>Shopping Choices:</h4>

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


.NET Framework
Available since 2.0
Return to top