Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:32:21+00:00 2026-05-31T18:32:21+00:00

I’m working on highlighting a repeater row when i click anywhere on that row.

  • 0

I’m working on highlighting a repeater row when i click anywhere on that row. And then when i click on another row, the previous row becomes unhighlighted. So it’s working, but only for a split second. Once the modalpopup appears, the highlight is gone. By the way, i have a linkbutton in every row that makes the modalpopup show, and i made all the labels inside the repeater as associatedcontrols. So the texts inside the repeater all kind of serve as linkbuttons. I know that the highlight-unhighlight thing works because the effect persist when i only click on the areas without text. I know the postback caused by clicking the linkbutton removes the effect made by javascript. What i want to know is, what can i do about it? Please help me.

Here’s my code.

Head:

<script type = "text/javascript">
    var T0;
    function CngClass(cls){
        this.lst=null;
        this.cls=cls;
    }

    CngClass.prototype.CngClass=function(obj){
        if (typeof(obj)=='string') obj=document.getElementById(obj);
        if (this.lst) this.lst.className='';
        obj.className=this.cls;
        this.lst=obj;
    }    

<style type="text/css">
    .selected
    {
        background-color: Red;
    }
</style>

Body:

<body onload="T0=new CngClass('selected');T0.CngClass('t0');">

ItemTemplate of the repeater:

<ItemTemplate> 
    <tr id="t0" runat="server" onclick="T0.CngClass(this);" onmouseover="style.backgroundColor='Gainsboro'" onmouseout="style.backgroundColor=''" style="cursor: pointer">
        <td><asp:Label ID="lblfullname" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FULLNAME")%>' AssociatedControlID="lnkselect" />
            <asp:HiddenField ID="hiddenrecnum" runat="server" Value='<%# DataBinder.Eval(Container.DataItem, "RECORD_ID")%>' />
        </td>
        <td><asp:Label ID="lbldeptname" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DEPT_NAME")%>' AssociatedControlID="lnkselect" /></td>
        <td><asp:Label ID="lbldivisions" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DIVISIONS")%>' AssociatedControlID="lnkselect" /></td>
        <td><asp:Label ID="lblposition" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "POSITION")%>' AssociatedControlID="lnkselect" />
            <asp:LinkButton ID="lnkselect" runat="server" /></td>
    </tr>
</ItemTemplate>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:32:23+00:00Added an answer on May 31, 2026 at 6:32 pm

    There are a few ways you could address this behavior.

    • Add a hidden field to the page which is set by JavaScript. Check the hidden field client or server-side and reapply the effect if the field has a value.

    • If clicking on the row is already causing a postback, you can set the selected style server-side and maintain the ID of the selected row in ViewState.

    Ideally you would minimize the number of the time the page reloads. Remember that the whole POST collection (which includes ViewState, which will be quite large with all those label controls in the repeater) is being sent to the server and being written back to the client with every postback.

    Example (Client + Server)

    In page markup:

    <!-- hidden field to store value -->
    <input type="hidden" id="hdnSelectedRow" runat="server" />
    
    <script>
    
    
    
    // This example doesn't use any external libraries, but I suggest using
    // jQuery if you want to do more complex manipulation client-side.
    function setSelectedRow(sender, id){
        sender.className = "selected";
        // probably need to also deselect any existing selected item
    
        // 
    
        // Store the selected ID in the hidden field. Note that we use the 
        // server's ID for the control, since ASP.NET may add a prefix to the ID.
        document.getElementById("<%=this.hdnSelectedRow.ClientID%>").value = id;
    }
    
    </script>
    
    <!-- This assumes that clicking on the row doesn't always postback the 
    whole grid. If you are always posting back, you probably should just modify
    the state of the grid server-side. -->
    <ItemTemplate> 
            <tr id="t0" runat="server" 
                        onclick="selectSelected(this, '<%#Eval("RECORD_ID")%>')">
    ...
    

    In codebehind:

    protected override OnLoad( EventArgs e )
    {
        string selectedId = this.hdnSelectedRow.Text;
        if( !string.IsNullOrWhiteSpace( selectedId ) )
        {
            // act
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.