Click here to Skip to main content
15,946,988 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
I need to change a tables class at runtime.

I used

tblButtonID.Attributes.Add("class", "DivButtonTableSearch2");

and works perfectly fine when i debug from my machine. When i run it on the server it doesn't work.

Any help please. Tried Uncle Google, no luck.

Ed Nutting 11-Apr-12 5:07am    
Why do you add the attribute many? Why aren't you using the built in CSSClass property? It has always works reliably for me and I suggest you try using it. If it doesn't work, is there any difference in version between your server code and debug code, different ASP.Net version possibly? Though I'm not sure that is very likely... Have you opened your server's web page in developer tools of Internet Explorer (or Chrome, Safari - they all have them). Look to see if your button has the expected class. If it does, check you have copied your CSS files across properly, if it doesn't then it is a code issue.

Hope this helps,
DJAppleboy 11-Apr-12 5:14am    
The problem is the styling is different. The one style works fine when i load it normally but after a click event the style has to change and thats when i have this line of code. As previously mentioned, locally it works fine but not on the server. In actual fact it doesnt even load the class on the server.
Ed Nutting 11-Apr-12 5:36am    
Very odd... Can you try debugging the code on the server (remote debugging) to see what is happening? Does other code in the click event work?
DJAppleboy 11-Apr-12 6:06am    
Have to clear the bin and re-compile. Hope that works

Check the css file on the server.Its updated or not.And clear the browser history some time it take from the temp files.These things you can try.
Share this answer
DJAppleboy 11-Apr-12 5:17am    
I've tried that, no luck. Tried

tblButtonID.Attributes["class"] = "DivButtonTableSearch2";

also and still doesn't work.
Anuj Banka 11-Apr-12 5:35am    
then try to put the table in div and apply the css to to div.Its just an idea :)
DJAppleboy 11-Apr-12 6:07am    
I've done that first. Thanks tho
Reload the complete application to the server
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900