 |
|
 |
Hello,
I have an image that has 4 polygon hotspots. I am able to get all the coordinates set for each polygon hotspot in the default.aspx page but the code behind I cannot figure out. I am not familiar with C# and the example shows to assign each JavaScript to the ID of each polygon hotspot. Can someone please help me out I have been stuck on this for 4 days.
Thanks in advance!!
Dale
|
|
|
|
 |
|
 |
Is there anyone who can help me out with this. I am desperate!! I have collection of 4 polygon hotspots within an imagemap and need each hotspot to have a rollover image. I am able to get one working with the demo but I cannot figure out how to write the code for the other 3 hotspots. PLEASE HELP!!
|
|
|
|
 |
|
 |
Here is my code that I have
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="YDreams.Web.UI.WebControls" Namespace="YDreams.Web.UI.WebControls"
TagPrefix="ydreams" %>
<!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 runat="server">
<title></title>
<script type="text/javascript">
function pageLoad() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
</div>
<div>
<ydreams:ImageMap ID="ImageMap1" ImageUrl="methodology_circle_green.gif" OnClick="ImageMap1_Click" runat="server">
<ydreams:CircleHotSpot CenterX="210" CenterY="45" Description="Click to test post back..."
HotSpotMode="PostBack" Radius="41" ToolTip="Post back" Id="AssessCircle" />
<ydreams:CircleHotSpot CenterX="310" CenterY="120" Description="Click to test post back..."
HotSpotMode="PostBack" Radius="41" ToolTip="Post back" Id="AnalyzeCircle" />
<ydreams:CircleHotSpot CenterX="270" CenterY="240" Description="Click to test post back..."
HotSpotMode="PostBack" Radius="41" ToolTip="Post back" Id="ArchitectCircle" />
<ydreams:CircleHotSpot CenterX="145" CenterY="240" Description="Click to test post back..."
HotSpotMode="PostBack" Radius="41" ToolTip="Post back" Id="AssembleCircle" />
<ydreams:CircleHotSpot CenterX="103" CenterY="120" Description="Click to test post back..."
HotSpotMode="PostBack" Radius="41" ToolTip="Post back" Id="AssimilateCircle" />
</ydreams:ImageMap>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
code behind - this is where I am having trouble adding rollover effects to CircleHotSpots - (AAnalyzeCircle, ArchitectCircle, AssembleCircle and AssimilateCircle) I am able to show rollover effects for AssessCircle but not the rest.
protected void Page_Load(object sender, EventArgs e)
{
YDreams.Web.UI.WebControls.CircleHotSpot circleHotSpot = (YDreams.Web.UI.WebControls.CircleHotSpot)this.ImageMap1.HotSpots["AssessCircle"];
if (circleHotSpot != null)
{
circleHotSpot.Attributes.Add("onMouseOver", "javascript:DisplayImage(image2);");
circleHotSpot.Attributes.Add("onMouseOut", "javascript:DisplayImage(image1);");
}
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);
}
}
If anyone can help me out with this I would appreciate it very, very much!! Thanks
|
|
|
|
 |
|
 |
Hi,
This Imagemap class is almost exactly what I'm looking for...I say almost because I found that using the postback feature fairly useless when I was using it my environment.
I have modified a copy of this code which includes a PostBackValue property, similar to the Microsoft one.
If you would like a copy of the code, or if YDreams would like to embed this into their original code , email me at paul.inglis (At) gmail.com
|
|
|
|
 |
|
 |
Hello,
Just an update on this control. There are 2 bugs that make this control pratically not usable:
1 - After the first fix (The one regarding pages with autopostback controls) now the control ONLY works IF there are other controls in the page with Autopostback on. Just try the demo project and delete the dropdown control to replicate this bug.
2 - The control will fire the OnClick even for each hotspot. In my scenario I have 30 hotspots in the image and so the onclick event will fire 30 times. This is not acceptable.
So i would suggest you not to waste your time with this control until is fixed.
Do you know any alternative control where I can use javascript on single hotspots?
Thanks
Marco
|
|
|
|
 |
|
 |
This control was my retribution to all the help I've had from this site for many years. I never requested fixes to the authors. I've always researched and posted the fixes back.
I have no time to fix the bugs and I have no more use for this control.
The code is open for all to see. Fix it yourself!...
|
|
|
|
 |
|
 |
It's ok, I didn't mean it in a bad way.
I wanted to give an update on the status of the control so that other people will not waste time if this doesn't suit their needs, or someone might fix the bugs.
However I do have some quick workarounds for them that might be useful:
1 - For the pages that do not have controls with autopostback you can insert a control with autopostback on and then put "display:none".
i.e.
<style type="text/css">
.displayNone{ display:none; }
</style>
<asp:DropDownList ID="DropDownList1" AutoPostBack="true" CssClass="displayNone" runat="server">
<asp:ListItem>Needed for hotspot bug
2 - For the bug that the event fires for each hotspot you can set an if statement like this:
bool firstTime = true;
protected void ImageMap_Click(object sender, YDreams.Web.UI.WebControls.ImageMapClickEventArgs args)
{
if (firstTime)
{
firstTime = false;
....... your code here ........
}
}
I don't have time to fix the control but I hope this helps.
And thanks for sharing this control with all of us
Marco
|
|
|
|
 |
|
 |
Ola.
Reparei que já é utilizador deste fantástico Site há mais de 5 anos!
Parabéns pelo sucesso da sua empresa YDREAMS.
Cumprimentos.
|
|
|
|
 |
|
 |
I have an asp.net page with some vb code that changes an image based on the textchanged event from a combobox. Changing the image works just fine. But I need to change the image to an image map with different hotspots defined based on the image selected. Can this control be used to do that? If not, does anyone have any idea how to do that? Please reply to me at bry at herp dot com
|
|
|
|
 |
|
 |
It looks like the imagemap onclick event is fired for each hotspot, though all the raised events have the correct arguments, the hotspot that was actually clicked. I don't have much experience in creating custom controls, and couldn't find the exact problem area.
Also, when using it with ajax, the postback still happens. The problems might be related.
|
|
|
|
 |
|
 |
I suffered exactly the same problem. I'm looking into it now, although any help would be very much appreciated.
|
|
|
|
 |
|
 |
I can't get around this, so it renders the control useless for me.
Has anybody found a way around this?
I've tried assigning the postback property to each hotspot in the code-behind and in the html, but the result is still the same.
|
|
|
|
 |
|
 |
Hi,
I was playing with .net iamgemap control for a long time to embed mouse over functionality and I give up and thought of creating a derived control. Before that I wanted to do some research and got urs. Great Job!. I have a second task to do, test the control with AJAX stuff.
Can you update us if there are any issues related to AJAX (Atlas) if you are aware of any?.
Thanks,
shashi.
|
|
|
|
 |
|
 |
In the former version of YDreams' Imagemap, the OnClick event was fired in the RaisePostBackEvent.
Now it is fired in the LoadPostData event.
This causes inconsistent behavior compared to other controls.
Also it causes the following problem:
When you add a Hotspot Dynamically. example: ImageMap1.HotSpots.Add(hotspot);
The OnClickEvent is fired to early, so the eveentArg of the OnClickEvent doesn't contain the Hotspot.
I propose Implement IPostBackEventHandler's RaisePostBackEvent.
Values you need (only eventArgument, rename it to prevent conficts), can be saved as local fields.
Regards.
BTW. I Like the Component !
FT 62
|
|
|
|
 |
|
 |
Is there any way that you can show how this can be accomplished? This component is great, but I need the capability do dynamically add hotspots, and not being able to retrieve the hotspot on the image_click event is throwing a wrench in the works.
Thanks!
|
|
|
|
 |
|
 |
Dear Winterblade,
Since i cannot send you my version of imagemap.cs hereby some lines of code...
You can see what I’ve commented out, an probably what I put in….
I believe it to be a quick fix.
You must however add your hotspots in every Page_Load.
public class ImageMap
: Image
, IPostBackDataHandler /* Added IPostBackEventHandler (FT)*/ , IPostBackEventHandler
bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
string eventTarget = postCollection["__EVENTTARGET"];
if (eventTarget != this.UniqueID)
return false;
// string eventArgument = postCollection["__EVENTARGUMENT"];
// FT: changed into:
eventArg = postCollection["__EVENTARGUMENT"];
// validate the event
ClientScriptManager clientScriptManager = this.Page.ClientScript;
clientScriptManager.ValidateEvent(this.UniqueID, eventArg); //changed into local field eventArg (FT)
//moved to the RaisePostBackEvent method (FT)
/* // raise the event
HotSpot hotSpot = null;
if (this.hotSpots != null)
{
int hotSpotIndex = int.Parse(eventArgument, CultureInfo.InvariantCulture);
if ((hotSpotIndex >= 0) && (hotSpotIndex < this.hotSpots.Count))
{
hotSpot = this.hotSpots[hotSpotIndex];
}
} */
// changed x and y into local fields (FT)
x = int.Parse(postCollection["__IMAGEMAP_X"], CultureInfo.InvariantCulture);
y = int.Parse(postCollection["__IMAGEMAP_Y"], CultureInfo.InvariantCulture);
//moved to the RaisePostBackEvent method (FT)
// this.OnClick(hotSpot, x, y);
return true;
}
public void RaisePostBackEvent(string eventArgument)
{
HotSpot hotSpot = null;
if (this.hotSpots != null)
{
int hotSpotIndex = int.Parse(eventArg, CultureInfo.InvariantCulture);
if ((hotSpotIndex >= 0) && (hotSpotIndex < this.hotSpots.Count))
{
hotSpot = this.hotSpots[hotSpotIndex];
}
}
this.OnClick(hotSpot, x, y);
}
// FT: added:
string eventArg = string.Empty;
int x = int.MinValue;
int y = int.MinValue;
}
|
|
|
|
 |
|
 |
Thank you for your response. It is still returning an object not found error. I will continue to work on this. Thank you again for your response.
|
|
|
|
 |
|
 |
I'd like to apply a color to each of the areas. Is there any way to do that short of swapping out images on mouseover?
Thanks!
|
|
|
|
 |
|
 |
I am trying to run the demo / source ..I tried to open it using VS 2005..but..An error is flagged saying ..DLL not found ..
What should I do ?
Aditi
|
|
|
|
 |
|
 |
That's very strange! I've downloaded the source and had no problems.
The controls only depends of .NET assemblies...
Do you know the name of the DLL that it says it's missing?
|
|
|
|
 |
|
 |
Great control, but the event handlers won't fire if there are other controls on the page that involve javascript hooking up of events for postback
(ir dropdownlist control).
Cheers,
A
|
|
|
|
 |
|
 |
I am trying to run the demo / source ..I tried to open it using VS 2005..but..An error is flagged saying ..DLL not found ..
What should I do ?
Pradnya
|
|
|
|
 |
|
 |
Great control - Works great... Until I place a standard asp.net dropdown list on the same page and set its auto-postback property to true. I'm guessing the JS injected by the dropdown list to hook-up the auto-postback event conflicts with the JS code written by the custom control to capture the clicked coordinates and pass them through to the click-event.
Basically the Click-event of the custom control just doesn't fire in this situation. I've stepped through the code and everything else in the page lifecycle fires except the click-event.
Anyway, I'm not too gifted with JS so I was wondering if anyone can spot the culprit when comparing the output of the two pages... I've created an example of a functioning and non-functioning page below:
* Functioning (dropdownlist autopostback enabled): http://www.thebunse.com/test/clickeventfires.aspx
* Not functioning (dropdownlist autopostback disabled): http://www.thebunse.com/test/clickeventfails.aspx
The code is identical in both pages except for the auto-postback property of the dropdownlist.
Any ideas?
Thanks in advance,
Andrew
|
|
|
|
 |
|
 |
Hi,
I'm trying to use the control in a project but when I click on the HotSpot the Handler is not executed in the codebehind. My browser does a postback when clicking, but no code is executed. How could I fix or test this?
|
|
|
|
 |
|
 |
Same here. I've checked the hooks, re-added the image, stepped through in debug mode but it just won't fire.
However If a create a new page in the project and add a new imagemap it works fine..
Something in the original page has changed which seems to have caused an incompatibility with your control..
Any ideas?
|
|
|
|
 |