Example of asp.net ImageMap control
Example of ImageMap in Asp.net:
In asp.net programming Image Map control is a collection of
more than one hotspots. Here we give a very basic Example to define this Image
Map concept in web development. In this
Image Map Example we consider an image Map with id Imagemap1, One Label control.
Example code of Asp.net Image Map:
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>asp.net ImageMap use</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">Image
Map control </h2>
<asp:Label
ID="Label1"
runat="server"
>
</asp:Label>
<br />
<asp:ImageMap
ID="ImageMap1"
runat="server"
ImageUrl="~/Images/Flower1.jpg"
HotSpotMode="PostBack"
OnClick="ImageMap1_Click"
>
<asp:RectangleHotSpot
Top="0"
Bottom="360"
Left="0"
Right="180"
/>
<asp:RectangleHotSpot
Top="0"
Bottom="360"
Left="181"
Right="360"
/>
</asp:ImageMap>
</div>
</form>
</body>
</html>
Example .Aspx.cs page for Image Map:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default :
System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Label1.Text = "Click and doll!";
ImageMap1.BorderWidth = 3;
ImageMap1.BorderStyle = BorderStyle.Double;
ImageMap1.BorderColor = System.Drawing.Color.Crimson;
}
}
protected void
ImageMap1_Click(object sender, ImageMapEventArgs e)
{
Label1.Text = "ckeck on: "
+ e.PostBackValue;
}
}
Comments
Post a Comment