473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Highlighting part of table when a hotspot is clicked

I'm working on asomething that has an image map with multiple hotspots. When the hotspot is clicked, I need it to highlight a particular row in the table that gives information about the person that was clicked on.

I know how to highlight the row using the BackColor part like I did here:

Expand|Select|Wrap|Line Numbers
  1. <asp:Table ID="Table1" runat="server" border="1">
  2.                                     <asp:tablerow BackColor="LightBlue">
  3.                                         <asp:tablecell>
  4.                                         <B>Instructor Name</B>
  5.                                         </asp:tablecell>
  6.                                         <asp:tablecell>
  7.                                         <B>Certification Level</B>
  8.                                         </asp:tablecell>
  9.                                     </asp:tablerow>
But how can I use it in this part of the code??:

Expand|Select|Wrap|Line Numbers
  1. protected void instructor_Clicked(object sender, ImageMapEventArgs e)
  2.     {
  3.         switch (e.PostBackValue)
  4.         {
  5.             case "Jardina":
  6.                 **Need to highlight Row1 in the table here**
  7.                 break;
Any help would be greatly appreciated. Thanks!
Mar 22 '10 #1
4 3260
CroCrew
564 Expert 512MB
Hello stitch121103,

Below is an example.

Expand|Select|Wrap|Line Numbers
  1.         <asp:ImageMap ID="ImageMap1" runat="server" ImageUrl="Images/MichiganRegions.gif" Height="800px" Width="800px">
  2.             <asp:CircleHotSpot Radius="100" X="200" Y="200" HotSpotMode="PostBack" NavigateUrl="#" PostBackValue="1" AlternateText="Row 1" />
  3.             <asp:CircleHotSpot Radius="100" X="400" Y="400" HotSpotMode="PostBack" NavigateUrl="#" PostBackValue="2" AlternateText="Row 2" />
  4.             <asp:CircleHotSpot Radius="100" X="600" Y="600" HotSpotMode="PostBack" NavigateUrl="#" PostBackValue="3" AlternateText="Row 3" />
  5.         </asp:ImageMap>
  6.  
  7.         <asp:Table ID="Table1" runat="server" border="1"> 
  8.             <asp:tablerow> 
  9.                 <asp:tablecell>Row 1 Cell 1</asp:tablecell> 
  10.                 <asp:tablecell>Row 1 Cell 2</asp:tablecell> 
  11.             </asp:tablerow> 
  12.             <asp:tablerow> 
  13.                 <asp:tablecell>Row 2 Cell 1</asp:tablecell> 
  14.                 <asp:tablecell>Row 2 Cell 2</asp:tablecell> 
  15.             </asp:tablerow> 
  16.             <asp:tablerow> 
  17.                 <asp:tablecell>Row 3 Cell 1</asp:tablecell> 
  18.                 <asp:tablecell>Row 3 Cell 2</asp:tablecell> 
  19.             </asp:tablerow> 
  20.         </asp:Table>
  21.  
Expand|Select|Wrap|Line Numbers
  1.     Protected Sub ImageMap1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) Handles ImageMap1.Click
  2.         Table1.Rows(0).BackColor = Drawing.Color.White
  3.         Table1.Rows(1).BackColor = Drawing.Color.White
  4.         Table1.Rows(2).BackColor = Drawing.Color.White
  5.  
  6.         Select Case e.PostBackValue
  7.             Case 1
  8.                 Table1.Rows(0).BackColor = Drawing.Color.Blue
  9.             Case 2
  10.                 Table1.Rows(1).BackColor = Drawing.Color.Blue
  11.             Case 3
  12.                 Table1.Rows(2).BackColor = Drawing.Color.Blue
  13.         End Select
  14.     End Sub
  15.  
Happy Coding,
CroCrew~
Mar 24 '10 #2
Ok, So I tried changing my code around a little to match the example you gave so I could make sure I understood how it was working, but I'm getting the following error:

Compiler Error Message: CS1002: ; expected

Source Error:

Line 8: public partial class instructors : System.Web.UI.Page
Line 9: {
Line 10: Protected Sub ImageMap1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) Handles ImageMap1.Click
Line 11: Table1.Rows(0).BackColor = Drawing.Color.Blue
Line 12: Table1.Rows(1).BackColor = Drawing.Color.White


And here's the code if you need it:

(from instructors.aspx)
Expand|Select|Wrap|Line Numbers
  1. <asp:ImageMap ID="ImageMap1"
  2.                     ImageURL="images/instructors.jpg"
  3.                     runat="server" 
  4.                     AlternateText="Image of a group of kayaking instructors"
  5.                     Width="447" Height="266">
  6.  
  7.                 <asp:RectangleHotSpot
  8.                     AlternateText="Image of a kayaking instructor- Jardina"
  9.                     Left="20" Top="60" Right="104" Bottom="236"
  10.                     HotSpotMode="PostBack" PostBackValue="1" />
  11.  
  12.                 <asp:RectangleHotSpot
  13.                     AlternateText="Image of a kayaking instructor- Cheung"
  14.                     Left="96" Top="17" Right="172" Bottom="169"
  15.                      HotSpotMode="PostBack" PostBackValue="2" />
  16.  
  17.                 <asp:RectangleHotSpot
  18.                     AlternateText="Image of a kayaking instructor - Reimer"
  19.                     Left="172" Top="17" Right="235" Bottom="165"
  20.                     HotSpotMode="PostBack" PostBackValue="3" />
  21.  
  22.                 <asp:RectangleHotSpot
  23.                     AlternateText="Image of a kayaking instructor- Miolla"
  24.                     Left="235" Top="26" Right="297" Bottom="155"
  25.                     HotSpotMode="PostBack" PostBackValue="4" />
  26.  
  27.                 <asp:RectangleHotSpot
  28.                     AlternateText="Image of a kayaking instructor- Lembright"
  29.                     Left="297" Top="23" Right="370" Bottom="158"
  30.                     HotSpotMode="PostBack" PostBackValue="5" />
  31.  
  32.                 <asp:RectangleHotSpot
  33.                     AlternateText="Image of a kayaking instructor- Yaron"
  34.                     Left="370" Top="24" Right="436" Bottom="128"
  35.                     HotSpotMode="PostBack" PostBackValue="6" />
  36.  
  37.                 </asp:ImageMap>
Expand|Select|Wrap|Line Numbers
  1. <asp:Table ID="Table1" runat="server" border="1">
  2.                                     <asp:tablerow>
  3.                                         <asp:tablecell><B>Instructor Name</B></asp:tablecell>
  4.                                         <asp:tablecell><B>Certification Level</B></asp:tablecell>
  5.                                     </asp:tablerow>
  6.  
  7.                                     <asp:tablerow>
  8.                                         <asp:tablecell>Bob Jardina</asp:tablecell>
  9.                                         <asp:tablecell>Swift-Water Rescue Instructor</asp:tablecell>
  10.                                     </asp:tablerow>
  11.  
  12.                                     <asp:tablerow>
  13.                                         <asp:tablecell>Lisa Cheung</asp:tablecell>
  14.                                         <asp:tablecell>River Guide Training Instructor</asp:tablecell>
  15.                                     </asp:tablerow>
  16.  
  17.                                     <asp:tablerow>
  18.                                         <asp:tablecell>Judy Reimer</asp:tablecell>
  19.                                         <asp:tablecell>Kayak Instructor II</asp:tablecell>
  20.                                     </asp:tablerow>
  21.  
  22.                                     <asp:tablerow>
  23.                                         <asp:tablecell>Wendy Miolla</asp:tablecell>
  24.                                         <asp:tablecell>Kayak Instructor I</asp:tablecell>
  25.                                     </asp:tablerow>
  26.  
  27.                                     <asp:tablerow>
  28.                                         <asp:tablecell>Jody Lembright</asp:tablecell>
  29.                                         <asp:tablecell>Kayak Instructor II</asp:tablecell>
  30.                                     </asp:tablerow>
  31.  
  32.                                     <asp:tablerow>
  33.                                         <asp:tablecell>Dave Yaron</asp:tablecell>
  34.                                         <asp:tablecell>River Guide Training Instructor</asp:tablecell>
  35.                                     </asp:tablerow>
  36.  
  37.                                 </asp:Table>
(this is from instructors.aspx.cs)
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. public partial class instructors : System.Web.UI.Page
  9. {
  10.     Protected Sub ImageMap1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) Handles ImageMap1.Click
  11.         Table1.Rows(0).BackColor = Drawing.Color.Blue
  12.         Table1.Rows(1).BackColor = Drawing.Color.White
  13.         Table1.Rows(2).BackColor = Drawing.Color.White
  14.         Table1.Rows(3).BackColor = Drawing.Color.White
  15.         Table1.Rows(4).BackColor = Drawing.Color.White
  16.         Table1.Rows(5).BackColor = Drawing.Color.White
  17.         Table1.Rows(6).BackColor = Drawing.Color.White
  18.  
  19.         Select Case e.PostBackValue
  20.             Case 1
  21.                 Table1.Rows(1).BackColor = Drawing.Color.Yellow
  22.             Case 2
  23.                 Table1.Rows(2).BackColor = Drawing.Color.Yellow
  24.             Case 3
  25.                 Table1.Rows(3).BackColor = Drawing.Color.Yellow    
  26.             Case 4
  27.                 Table1.Rows(4).BackColor = Drawing.Color.Yellow
  28.             Case 5
  29.                 Table1.Rows(5).BackColor = Drawing.Color.Yellow
  30.             Case 6
  31.                 Table1.Rows(6).BackColor = Drawing.Color.Yellow
  32.         End Select
  33.     End Sub
  34. }
  35.  
Do you know what's causing that error? Am I putting something in the wrong place?...if so, where should it be. Sorry if I sound so lost.... haven't really done much with ASP.
Mar 24 '10 #3
CroCrew
564 Expert 512MB
Try this:

Expand|Select|Wrap|Line Numbers
  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.Linq; 
  4. using System.Web; 
  5. using System.Web.UI; 
  6. using System.Web.UI.WebControls;
  7.  
  8. public partial class instructors : System.Web.UI.Page 
  9.     protected void  ImageMap1_Click1(object sender, ImageMapEventArgs e)
  10.     {
  11.         Table1.Rows[0].BackColor = System.Drawing.Color.Blue;
  12.         Table1.Rows[1].BackColor = System.Drawing.Color.Blue;
  13.         Table1.Rows[2].BackColor = System.Drawing.Color.Blue;
  14.         Table1.Rows[3].BackColor = System.Drawing.Color.Blue;
  15.         Table1.Rows[4].BackColor = System.Drawing.Color.Blue;
  16.         Table1.Rows[5].BackColor = System.Drawing.Color.Blue;
  17.         Table1.Rows[6].BackColor = System.Drawing.Color.Blue;
  18.  
  19.         switch(e.PostBackValue)
  20.         {
  21.             case "1":
  22.                 Table1.Rows[0].BackColor = System.Drawing.Color.Yellow;
  23.                 break;
  24.             case "2":
  25.                 Table1.Rows[1].BackColor = System.Drawing.Color.Yellow;
  26.                 break;
  27.             case "3":
  28.                 Table1.Rows[2].BackColor = System.Drawing.Color.Yellow;
  29.                 break;
  30.             case "4":
  31.                 Table1.Rows[3].BackColor = System.Drawing.Color.Yellow;
  32.                 break;
  33.             case "5":
  34.                 Table1.Rows[4].BackColor = System.Drawing.Color.Yellow;
  35.                 break;
  36.             case "6":
  37.                 Table1.Rows[5].BackColor = System.Drawing.Color.Yellow;
  38.                 break;
  39.             case "7":
  40.                 Table1.Rows[6].BackColor = System.Drawing.Color.Yellow;
  41.                 break;
  42.         }
  43.     }
  44.  

Happy Coding,
CroCrew~
Mar 25 '10 #4
Frinavale
9,735 Expert Mod 8TB
Just so you know, every line in C# must be terminated with a ";"
:)

-Frinny
Mar 25 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: The Lone Wolf | last post by:
Hi, is it possible to put somekind of parameter on a table that when i put data into the table it automaticly erase the row when a certain time has past?? i know i can use cookies on the...
2
by: FSJOSEPH | last post by:
To the Group: Hi all, I am using a java/pdf report engine namely Elixir Report Server. The report server uses JDK 1.4.1 with hotspot server JVM support. My application runs on AIX and the...
14
by: lance | last post by:
Hi, I am a JS newbie. Hopefully the answer to my question is not trivial. I have written a simple webpage that presents a table. A JS function allows the viewer to click on a cell and each...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
2
by: Tor Inge Rislaa | last post by:
Showing an HTML file in part of a Webform Hi I have a Webform with some buttons on the left side of the form. What I want when clicking one of the buttons is to show an HTML document in a part...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
7
by: Arnold | last post by:
Greetings Gurus, In a mainform's header, I have a combobox named comboStudents. The rowsource for this combobox is: SELECT -999 As StudentID, "<Add New Student>" As FullName, "aaa" As...
6
by: Icare-Infographie | last post by:
hi, how can i start a query after i have selected a hotspot on a map ? i use vs 2003. a javascript ? many thanks, jpm
5
by: Tom | last post by:
I am having a problem where an extra gap (whitespace, padding) appears in a table cell where I don't want it. The data fed in the table is via dynamic HTML, so the amount in the middle cell may...
1
by: russiandevil | last post by:
hi, Does anyone have an idea on how I'd go about highlighting (with a border, or something equally effective) a input button of type 'image' (i.e. <input type=image alt=Login src=http://<etc,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.