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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change cssClass for cell table (onClick onMouseOver, onMouseOut)

Status
Not open for further replies.

bereza

Technical User
Jun 14, 2006
105
EU
Hi everybody,

I am trying to change cssClass for a cell table (td) which contatins a LinkButton(to navigate to home.aspx) by using onclick, onMouseOver and OnMouseOut.
onMouseOver and onMouseOut work good, But the problem is onclik, when the linkbutton within the cell is clicked the page is posted back and the cell gets its old cssClass from the markup. here is the code

<td class="MenuItem" id="MyTD" onmouseover="SetClass('MyTD', 'ItemMouseOver')" onmouseout="SetClass('MyTD', 'ItemMouseOut')" onclick="SetClass('MyTD', 'ItemMouseClick') >
<asp:LinkButton ID="lbHome" runat="server" Text="Home" OnClick="lbHome_Click"></asp:LinkButton>
</td>

//javascript

function SetClass(id, myclass) {
if (document.all(id).className != "ItemMouseClick") {
document.all(id).className = myclass;
}
}

 
hi and thanks

i have showed the real client side code,

It is all I have.
 
Client side code is what appears on the client's browser. What you have shown is the server side code, which your server translates and then sends something different to the client.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Whatever the event you choose, you simply need
Code:
document.getElementById('id_goes_here').className="change_to_this_class_name";

That should do the trick!

Of course, there is the concern of changing the class back to its default if needed ... Just thought I mention it.

Hope this helps!


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top