views:

46

answers:

2

Hi,

I have an ImageMap control in an ascx file of mine. I'm trying to make something happen when the user clicks on an area in the map, but the page just posts back without my "imageMap_Click" event handler never being invoked. Suggestions?

<asp:ImageMap ID="imageMap" runat="server" ImageUrl="~/images/MapImages/map.jpg" HotSpotMode="PostBack" OnClick="imageMap_Click">

My imageMap_Click looks like this, just to see if it's invoked at all:

    protected void imageMap_Click(object sender, ImageMapEventArgs e)
    {
        throw new NotImplementedException();
    }
A: 

Just from the docs, shouldn't your image map have the different locations in it for the click mapping?

eg:

<asp:ImageMap ID="SaturnImage" 
  ImageUrl="~/saturn.PNG" 
  runat="server" OnClick="SaturnImage_Click">
  <asp:CircleHotSpot AlternateText="planet" HotSpotMode=PostBack
    PostBackValue="planet" Radius=40 X=100 Y=100 />
  <asp:CircleHotSpot HotSpotMode=Inactive 
    Radius=60 X=100 Y=100 />
  <asp:CircleHotSpot AlternateText="rings" HotSpotMode=PostBack
    PostBackValue="rings" Radius=80 X=100 Y=100 />
</asp:ImageMap>

Because I'm assuming with ImageMap that when you click on it it only does the postback if you click on a part which is set up to be clicked. It shouldn't generated a clicked event if none of the mapped parts are clicked on.

Paul
A: 

I've found it already. It was due to the control having viewstate disabled, like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MapControl.ascx.cs" Inherits="XXX.MapControl" EnableViewState="false" %>

I don't understand why. Anyone care to tell me?

Microserf