SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a simple webpart to show the weather forecast and I need to put it into a wiki page. The thing is: it works perfectly on a webpart page, but inside a wiki it is shown like it doesn't have css, everything it out of place. When I go to the designer, I can put it on the bottom placeholder and it works, but if I put it on the top one, the PlaceHolderMain and click save, it doesn't work, it simply erases my webpart warning me of unsafe content. By the definition of the site I'm working with I can't put it into the bottom, it must be inside the PlaceHolderMain. HELP ME!!!

share|improve this question
May be take a Web Part Zone and place inside it... – Arsalan Adam Khatri Dec 20 '12 at 13:44
up vote 0 down vote accepted

I have a question if you dont mind? if you have created a custom webpart why dont you add the css sepratly? surely the css could be added to 12Hive or 14Hive?

so in your webpart you have a testbox or label and add a cssClass attribute to it like so

textbox1.CssClass = "editTextbox";

now add your custom css class file to 12hive in the following location:


or in your webpart in visual studios goto your solution explorer on the right, create a new folder within the project called "12" within 12 a new folder "templates" within templates a new folder "LAYOUTS"...... you get the message you basicly need to recreate the folder directory where you want to store the css class and add the css file into that final folder within the project. when you deploy the wsp (webpart) it will navigate to the selected folder location and put in the css class for you :) so you dont have to touch 12hive what is best left alone ;)

go back to your webpart and add this in the creatChildControls event to call upon the css class:


in your css (styles.css)

   margin: 20px;

bingo :)

share|improve this answer
That's exactly what I did! :) My webpart's css was already fixed like this.. and still doesn't work, but only on wiki pages. Actually it can find my css file, cause I give it a background image on the css, and it shows up... so... but still all my images and divs are on/under each other, not as I configured on the css file... do you understand what I mean? – Ubi Dec 20 '12 at 14:18
have you set the !important; attribute on your css? so as an example "position:relative !important;" that will force the css to show :) – ali Sharepoint Dec 20 '12 at 16:08
Thanks for your answer and sorry for the late reply. Actually, what I did was just prefix my CSS classes. They were messed up cause of others css. – Ubi Apr 26 '14 at 5:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.