Login | Register
Blog
Feb 3

Written by: Dylan Barber
2/3/2010 10:42 AM  RssIcon

With jQuery and CSS becoming so much more the norm for web development it becomes even more necessary to be able to manipulate classes on elements not in the skin, specifically the body tag.

 

There are really two ways to do this and each has it benefits and problems, jQuery and inline code.

Jquery: This method is so simple simply add in the skin and it will add whatever class to the body tag, in DNN the id of the body tag is ‘Body’. The only problem with this method is if you are depending on that class being there even if jQuery fails to run you are out of luck.

Inline Code: the method uses a simple bit of inline vb.net code to add the class to the body tag

Now this method will work as long as DNN works it only depends on the ASP.NET parser parsing the file out as it will have to for any DNN portal to work. The problem here is there is that millisecond of more processing.

 

Both methods are valid and work fine – I think the second method is a bit more reliable since a user could have JavaScript turned off on the client then your site may look strange if you have coded CSS classes for the body.


Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
 
Categories
Skip Navigation Links.
Search
Tags
Recent Entries
First Published Module (Timed Skins) – DNN 5 Version
CodeMyPantsOff First Published Module (Timed Skins)
Online Jobsites and Politics – A Rant Maybe?
Mass Tabs – the free way to build a huge site quickly
Find My DNN Portal
My 5 Favorite Objects for DNN Portals
Work Smarter, Not harder (maybe?)
Playing with the new DNN Blog (4.00.00 Beta 3)
Archive
Privacy Statement | Terms Of Use
Copyright 2008 by Code My Pants Off