Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET equivalent to USEMAP 2

Status
Not open for further replies.

dave755

IS-IT--Management
May 3, 2001
69
0
0
US
I am sure there must be a way to do this, but I have been reading the books & sites for hours with no luck. Please enlighten me.

I am creating a bitmap image in code using GDI+ and displaying it on my page with an <asp:image .../> tag. What I want to do is to make parts of the image clickable. In ASP, this is easily accomplished with the USEMAP attribute and the <MAP> HTML tag.

I can easily put buttons around the bitmap, but this does not seem very intuitive for the user. It would make the most sense to have the user click directly on the image.

How do you do this in ASP.NET?

Dave Gee
 
Maybe try the attributes.add method:

Image1.Attributes.Add("USEMAP","your map name)


Jim
 
dave: This is an interesting problem - in my case I have always had image maps generated by a 3d party charting package, etc, so haven't seen much on ASP.NET's capabilities here. Framework 2.0 has an "ImageMap" object, are you using this version? I'll be running around the net today so will keep an eye out for ya and post back if I come across more information -- how did Jim's suggestion come out? Any luck with adding it as an attribute?
 
Thanks, Jim for the tip.

To make this work, my code looks like this:
Code:
Dim sMap As String
Dim qt As String = Chr(34)
Image1.Attributes.Add("USEMAP", "#ClickMap")
sMap = "<MAP name=" & qt & "ClickMap" & qt & ">" & vbCrLf

... construct graphic image in a loop ...
...  including calculating rectangle "r1" ...

sMap &= "<AREA href=" & qt & "TargetPage.Aspx" & qt & _
        " shape=" & qt & "rect" & qt & _
        " coords=" & qt & r1.Left.ToString() & "," & _
                          r1.Top.ToString() & "," & _
                          r1.Right.ToString() & "," & _
                          r1.Bottom.ToString() & qt
sMap &= " title=" & qt & "some text" & qt & ">" & vbCrLf

... end loop ...

sMap &= "</MAP>" & vbCrLf

Then, I inserted the sMap string, ASP style, at the end of the HTML portion of my page.
Code:
<%=sMap%>

Dave Gee
 
It seems as though you are building up a potentially large string so you should consider using a StringBuilder rather than a String for your sMap variable (it will save memory and be faster).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top