Is there a simple override method to change the background of a webpart? SP 2010
Question
Found out how to change the background of one single page (body of that page). This works when I want a single page or two to have a specific background instead of modifying a master page.
Is there something similar to change the background color of a webpart? or add an image as the background? or even make it transparent?
Thanks as always!
Solution
Basically, it can be done with css with header and table changing:
.s4-wpTopTable {
background:
#FEE;
}
.ms-WPHeader {
background:
#FEE;
}
If you want to apply this to particular web-part, you can add additional css-marker class on you web-part render methods to find you web part instance later or use js/jQuery-client bases techniques to apply/change css on target webpart.
OTHER TIPS
The WebPart class has properties for background color and background image URL.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpart_properties
You can change the background by simply assigning relevant CSS to the topmost table or div tag that your webpart generates.For data-view, the html markup is in its XSL.