Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ListView with itemtemplate- Highlight selected row

ListView with itemtemplate- Highlight selected row

Scheduled Pinned Locked Moved ASP.NET
javascriptdesignsysadminhelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vjvjvjvj
    wrote on last edited by
    #1

    Hi, I have listview with itemtemplates. so listview's each row is in the format as In design it looks similar to as asp:ListView ID="ListviewSelectedBaseLayers" runat="server" DataKeyNames="Layer_ID"> .. .. Now when I click on checkbox or the label, listview's selected row does not hilight. How to achieve this? I tried by toggling the colour of the table covering table row by putting onclick javascript for the label. Did not find enough information on this ? So if anybody give some tips will really help. thanks vijay

    W 1 Reply Last reply
    0
    • V vjvjvjvj

      Hi, I have listview with itemtemplates. so listview's each row is in the format as In design it looks similar to as asp:ListView ID="ListviewSelectedBaseLayers" runat="server" DataKeyNames="Layer_ID"> .. .. Now when I click on checkbox or the label, listview's selected row does not hilight. How to achieve this? I tried by toggling the colour of the table covering table row by putting onclick javascript for the label. Did not find enough information on this ? So if anybody give some tips will really help. thanks vijay

      W Offline
      W Offline
      walterhevedeich
      wrote on last edited by
      #2

      You can do it through the onclick event of the tr element. Here's a simple snippet of what you might want to do.

      <tr style="border:solid 1px Black;" onclick="ToggleColor(event);">

      And on the function

      function ToggleColor(ev) {
      var tar;
      //IE and Firefox treats the event caller differently. This snippet is to make sure
      //that what we are selecting is the right element before setting its background color.
      if (ev.srcElement != null) {
      tar = ev.srcElement.parentElement;
      }
      else {
      tar = ev.currentTarget;
      }

      if (tar.bgColor == "#eeeeee") {
          tar.bgColor = "#ffffff";
      }
      else {
          tar.bgColor = "#eeeeee";
      };
      

      }

      Hope this helps.

      Walter

      P 1 Reply Last reply
      0
      • W walterhevedeich

        You can do it through the onclick event of the tr element. Here's a simple snippet of what you might want to do.

        <tr style="border:solid 1px Black;" onclick="ToggleColor(event);">

        And on the function

        function ToggleColor(ev) {
        var tar;
        //IE and Firefox treats the event caller differently. This snippet is to make sure
        //that what we are selecting is the right element before setting its background color.
        if (ev.srcElement != null) {
        tar = ev.srcElement.parentElement;
        }
        else {
        tar = ev.currentTarget;
        }

        if (tar.bgColor == "#eeeeee") {
            tar.bgColor = "#ffffff";
        }
        else {
            tar.bgColor = "#eeeeee";
        };
        

        }

        Hope this helps.

        Walter

        P Offline
        P Offline
        PunkIsNotDead
        wrote on last edited by
        #3

        if you can make the list view render as divs I think you can use jQuery Highlight[^] Effect. :) good luck

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups