How to add custom CSS in your WebPart

By Namwar Rizvi - Last updated: Sunday, June 14, 2009 - Save & Share - Leave a Comment

If you want to add custom CSS file for your webpart, here is the code:

  1. protected override void CreateChildControls()
  2. {
  3. base.CreateChildControls();
  4. CssLink cssLink = new CssLink();
  5. cssLink.DefaultUrl = “/_layouts/Test.css”;
  6. this.Page.Header.Controls.Add(cssLink);
  7. }
Share
Posted in C#, Solutions, Tips • Tags: , , Top Of Page

Write a comment