Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Weird Image Map string problem (Read 3836 times)
rand_acs
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jan 23rd, 2007
Weird Image Map string problem
Feb 14th, 2007 at 2:54pm
Print Post  
Hi,

I use HtmlBuilder to get an Image map as a string and pass it to the client browser but are having some difficulties.

First this is how I use the HtmlBuilder class:

Code
Select All
HtmlBuilder hb = new HtmlBuilder(_flc);
map = hb.CreateImageMap("chart");
 



This string is returned and assigned in another class to a attribute of that class, imgMap. Here is how I want to "print to screen", Note phImageMap is a PlaceHolder instance on the custom control also containing the image of the graph:

Code
Select All
LiteralControl ltc = new LiteralControl();
ltc.Text = imgMap;
phImageMap.Controls.Add(ltc);
 



The first problem came when the string returned contained some escape characters, for example:

Code
Select All
"\t<MAP NAME=\"chart\">\r\n
\t\t<AREA SHAPE=\"RECT\" COORDS=\"316,182,366,232\"\r\n
\t\t\tHREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=28\" TARGET=\"_self\" TITLE=\"\">\r\n
\t\t<AREA SHAPE=\"RECT\" COORDS=\"316,32,366,82\"\r\n
\t\t\tHREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=27\" TARGET=\"_self\" TITLE=\"\">\r\n
\t\t<AREA SHAPE=\"RECT\" COORDS=\"166,257,216,307\"\r\n
\t\t\tHREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=26\" TARGET=\"_self\" TITLE=\"\">\r\n
\t\t<AREA SHAPE=\"RECT\" COORDS=\"166,107,216,157\"\r\n
\t\t\tHREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=25\" TARGET=\"_self\" TITLE=\"\">\r\n
\t\t<AREA SHAPE=\"RECT\" COORDS=\"16,182,66,232\"\r\n
\t\t\tHREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=24\" TARGET=\"_self\" TITLE=\"\">\r\n
\t</MAP>\r\n"
 



Now this project is using DOTNETNUKE and it seems that the html generating modules did not like these, so I wrote some regexp to clean those out.

Now at this point when I take the value of the string variable that gets passed(that is cleaned) and explicitly print that, example:

Code
Select All
phImageMap.Controls.Add(new LiteralControl("<MAP NAME=\"chart\"><AREA SHAPE=\"RECT\" COORDS=\"316,32,366,82\" HREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=28\" TARGET=\"_self\" TITLE=\"\"><AREA SHAPE=\"RECT\" COORDS=\"166,332,216,382\" HREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=27\" TARGET=\"_self\" TITLE=\"\"><AREA SHAPE=\"RECT\" COORDS=\"166,182,216,232\" HREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=26\" TARGET=\"_self\" TITLE=\"\"><AREA SHAPE=\"RECT\" COORDS=\"166,32,216,82\" HREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=25\" TARGET=\"_self\" TITLE=\"\"><AREA SHAPE=\"RECT\" COORDS=\"16,182,66,232\" HREF=\"/fburg/Default.aspx?TabId=523&CtrlView=ProcessSummary&ProcessId=10&ProcessGraphImage=Show&id=24\" TARGET=\"_self\" TITLE=\"\"></MAP>"));
 



the image map is generated over the image and it works very well. But when I assign the the variable "imgMap"(like showen in the second code snipped) it does not generated the image map.

Now I have two questions. The first is if there is a way to make HtmlBuilder not generate the string with all the escape characters etc? I did not see anything of the kind in the documentation. The second question is if someone can point me at the weird string assignment problem? I know this is likely something very silly but we can't find the problem.

Kind Regards.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Weird Image Map string problem
Reply #1 - Feb 14th, 2007 at 5:59pm
Print Post  
Hi,

There might be some difference between how the LiteralControl constructor and the literal' Text property process the assigned text. What happens if you use the variable as below?

phImageMap.Controls.Add(new LiteralControl(imgMap));

At this time the tabs and new lines are hard-coded. Until we fix that, try using the String.Replace method to replace them with empty strings.

Stoyan
  
Back to top
 
IP Logged
 
rand_acs
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jan 23rd, 2007
Re: Weird Image Map string problem
Reply #2 - Feb 19th, 2007 at 9:52am
Print Post  
Hi,

I've tried multiple ways of writing the string now, including the one you suggested. No luck. Even when using:
Code
Select All
Response.Write(imgMap);
 


it did not work, so I doubt it's something to do with the Literal or LiteralControl classes.

I was thinking that it might be .NET that does something with the string variable. Since, like I stated previously, when I explicitly put the data retrieved from memory dumps into the code, using Response.Write and PlaceHolder it work perfectly. So we tried:
Code
Select All
String.Format("{0}", imgMap);
 


before writing it, but yet again this did not work.

Any other ideas no this problem? Maybe some way of recreating the string like the String.Format attempt?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Weird Image Map string problem
Reply #3 - Feb 19th, 2007 at 12:01pm
Print Post  
Are you sure the "imgMap" variable is set at the time when the literal control is created? Could you add a breakpoint on the

ltc.Text = imgMap;

line and check what's the imgmap value when the breakpoint hits?

Stoyan
  
Back to top
 
IP Logged
 
rand_acs
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jan 23rd, 2007
Re: Weird Image Map string problem
Reply #4 - Feb 26th, 2007 at 8:30am
Print Post  
Yes the imgMap variable is set and the map is written now as seen when viewing source. The problem was a loading issue with the string of the map and the image data, due to this being a control in a control in a page(being a control) etc...

So with this done I thought my troubles was over but not quite yet. For some reason the string generated by HTMLBuilder(without any manipulation) works perfectly in Firefox but not IE7. Any ideas on why? This is the code as seen in the source through IE7's "view source":

Code
Select All
<div id="processGraphImage">
<img id="dnn_ctr882_ProcessMainView_ctrlProcessSummary_ProcessGraphImage_processImage" usemap="#chart" src="http://localhost/fburg/Default.aspx?TabId=523&amp;CtrlView=ProcessSummary&amp;ProcessId=10&amp;ProcessGraphImage=Show" alt="" border="0" />

<MAP NAME="#chart">


<AREA SHAPE="RECT" COORDS="316,32,366,82"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/ProcessId/10/Default.aspx?id=28" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="166,332,216,382"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/ProcessId/10/Default.aspx?id=27" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="166,182,216,232"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/ProcessId/10/Default.aspx?id=26" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="166,32,216,82"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/ProcessId/10/Default.aspx?id=25" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="16,182,66,232"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/ProcessId/10/Default.aspx?id=24" TARGET="_self" TITLE="">

</MAP>

</div>
 



Firefox's source looks exactly the same and works as stated above. In IE7 the the image is displayed but you can't click on the nodes.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Weird Image Map string problem
Reply #5 - Feb 26th, 2007 at 9:34am
Print Post  
There are two differences I can see between your code and the WebApp sample. The map's NAME attribute value should not contain #, which should be used in the img's USEMAP attribute. Maybe it appeared from the regular expressions you've mentioned? If that does not help, try moving the map code outside the div.

Stoyan
  
Back to top
 
IP Logged
 
rand_acs
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jan 23rd, 2007
Re: Weird Image Map string problem
Reply #6 - Feb 26th, 2007 at 12:00pm
Print Post  
Hi Stoyo,

Yes with the # not at the start of the name it does the same. Note that the map does not work in Firefox with the #. About the div, it's used to be without one and does not change IE7's behaviour without it. Also, there are no more regexp in my code. So the string I try to print is the exact one I get from HTMLBuilder.

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Weird Image Map string problem
Reply #7 - Feb 26th, 2007 at 12:24pm
Print Post  
I have inserted your code between body tags and it worked in both browsers:

Code
Select All
<html>

<body>

<div id="processGraphImage">
<img id="dnn_ctr882_ProcessMainView_ctrlProcessSummary_ProcessGraphImage_proc essImage" usemap="#chart" src="15_04 (30).JPG" alt="" border="0" />

<MAP NAME="chart">


<AREA SHAPE="RECT" COORDS="316,32,366,82"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/Pr ocessId/10/Default.aspx?id=28" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="166,332,216,382"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/Pr ocessId/10/Default.aspx?id=27" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="166,182,216,232"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/Pr ocessId/10/Default.aspx?id=26" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="166,32,216,82"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/Pr ocessId/10/Default.aspx?id=25" TARGET="_self" TITLE="">


<AREA SHAPE="RECT" COORDS="16,182,66,232"



HREF="/fburg/TASKMANAGEMENT/Process/tabid/523/CtrlView/ProcessSummary/Pr ocessId/10/Default.aspx?id=24" TARGET="_self" TITLE="">

</MAP>

</div>

</body>

<html>
 



Maybe something else on the page breaks the image map. E.g. if the map code is in a form, try how that will work if you move it out of the form.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint