المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : YDreams ImageMapDemo 2.0 Code Behind Issue



C# Programming
07-31-2009, 08:50 PM
Hello

I have an ImageMap created using YDreams ImageMapDemo 2.0. I'm using this control for the rollover image effect with circle and polygons hotspots. My issue is I can't seem to figure out how to write the correct C# code for each hotspot. I am able to get one hotspot to have the rollover effect but not the other 4. Can someone please help me out with the code behind. I am very very new with C+. Anyone's help would be much appreciated. Been banging my head for 2 months.

Thanks in advanced

Dale

Form code
































Code Behind

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
YDreams.Web.UI.WebControls.HotSpot AssessCircle = new YDreams.Web.UI.WebControls.CircleHotSpot(210, 45, 41);
{
ImageMap1.HotSpots.Add(AssessCircle);
{
// add OnMouseOver and OnMouseOut event handlers to the blue polygon hot spot
YDreams.Web.UI.WebControls.CircleHotSpot circleHotSpot = (YDreams.Web.UI.WebControls.CircleHotSpot)this.ImageMap1.HotSpots["AssessCircle"];
if (circleHotSpot != null)
{
circleHotSpot.Attributes.Add("onMouseOver", "**********:DisplayImage(image2);");
circleHotSpot.Attributes.Add("onMouseOut", "**********:DisplayImage(image1);");
}

// add the script called by the event handlers
string script = @"
var image1 = new Image(413, 285);
image1.src = 'methodology_circle_green.gif';
var image2 = new Image(413, 285);
image2.src = 'methodology_circle_blue_assess.gif';

function DisplayImage(image) {
var theImage = document.images['ImageMap1'];
if (!theImage) {
theImage = document.getElementById('ImageMap1');
}
theImage.src = image.src;
return true;
}
";

this.ClientScript.RegisterClientScriptBlock(this.GetType(), "DisplayImage", script, true);
}
}

YDreams.Web.UI.WebControls.HotSpot AnalyzeCircle = new YDreams.Web.UI.WebControls.CircleHotSpot(310, 120, 41);
{
ImageMap1.HotSpots.Add(AnalyzeCircle);
{
// add OnMouseOver and OnMouseOut event handlers to the blue polygon hot spot
YDreams.Web.UI.WebControls.CircleHotSpot circleHotSpot = (YDreams.Web.UI.WebControls.CircleHotSpot)this.ImageMap1.HotSpots["AnalyzeCircle"];
if (circleHotSpot != null)
{
circleHotSpot.Attributes.Add("onMouseOver", "**********:DisplayImage(image2);");
circleHotSpot.Attributes.Add("onMouseOut", "**********:DisplayImage(image1);");
}

// add the script called by the event handlers
string script = @"
var image1 = new Image(413, 285);
image1.src = 'methodology_circle_green.gif';
var image2 = new Image(413, 285);
image2.src = 'methodology_circle_blue_analyze.gif';

function DisplayImage(image) {
var theImage = document.images['ImageMap1'];
if (!theImage) {
theImage = document.getElementById('ImageMap1');
}
theImage.src = image.src;
return true;
}
";

this.ClientScript.RegisterClientScriptBlock(this.GetType(), "DisplayImage", script, true);
}
}
}
protected void ImageMap1_Click(object sender, YDreams.Web.UI.WebControls.ImageMapClickEventArgs args)
{
YDreams.Web.UI.WebControls.HotSpot hotSpot = args.HotSpot;
int x = args.X;
int y = args.Y;

// set the text of the label
this.Label1.Text = string.Format("Clicked on hot spot \"{0}\" at image coordinates ({1}, {2})", hotSpot.Id, x, y);
}

protected void Button1_Click(object sender, EventArgs e)
{
this.Label1.Text = string.Empty;
}

}