Koray Kırdinli

Yazılım ve İş Yaşamı Hakkında Paylaşımlar

ASP.NET ImageMap ile HotSpot

ImageMap kontrolü ile Web sayfanıza eklediğiniz bir resmin farklı noktalarına
HotSpot belirleyerek farklı aksiyonlar aldırabilirsiniz. HTML çıktısı  şu şekilde <img usemap=”#myMap”>

Belki bir yerde işinize yarar.

public partial class HotSpotControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ImageMapStopLight.ImageUrl = “~/images/stoplight.jpg”;
ImageMapStopLight.AlternateText = “Stoplight picture”;
ImageMapStopLight.HotSpotMode = HotSpotMode.PostBack;

RectangleHotSpot redHotSpot = new RectangleHotSpot();
redHotSpot.Top = 0;
redHotSpot.Bottom = 40;
redHotSpot.Left = 0;
redHotSpot.Right = 40;
redHotSpot.PostBackValue = “RED”;
ImageMapStopLight.HotSpots.Add(redHotSpot);

RectangleHotSpot yellowHotSpot = new RectangleHotSpot();
yellowHotSpot.Top = 41;
yellowHotSpot.Bottom = 80;
yellowHotSpot.Left = 0;
yellowHotSpot.Right = 40;
yellowHotSpot.PostBackValue = “YELLOW”;
ImageMapStopLight.HotSpots.Add(yellowHotSpot);

RectangleHotSpot greenHotSpot = new RectangleHotSpot();
greenHotSpot.Top = 81;
greenHotSpot.Bottom = 120;
greenHotSpot.Left = 0;
greenHotSpot.Right = 40;
greenHotSpot.PostBackValue = “GREEN”;
ImageMapStopLight.HotSpots.Add(greenHotSpot);

}
protected void ImageMapStopLight_Click(object sender, ImageMapEventArgs e)
{
Label1.Text = string.Format(“You clicked the {0} rectangle.”, e.PostBackValue);
}
}

January 13, 2012 - Posted by | ASP.NET | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s