I'm working on highlighting repeater 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 of the linkbutton. So the texts inside the repeater all kind of serve as linkbuttons. I know that the highlight-unhighlight thing works because the effect persists when i only click on the areas without text. I know the postback caused by clicking the linkbutton removes the highlight made by javascript. What i want to know is, what can I do about it? Please help me.
Here's my code:
<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;
}
</script>
<style type="text/css">
.selected
{
background-color: Red;
}
</style>
and then in the body it's like this:
<body onload="T0=new CngClass('selected');T0.CngClass('t0');">
then the itemtemplate of the repeater looks like this:
<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>