Thursday 22 March 2012

Adding CSS to ShaePoint Page or Custom Code Page

After a battle i found the solution "How to use CSS class inside a custom webpart page".

So to achieve this goal please follow the bellow steps,

1. Open the Solution File in Visual Studio (Webpart Page)
2. Do the changes in ChildControl Method

protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
            CssRegistration.Register("/Style%20Library/coreV5.css");
                      
        }
3. If you are creating a runtime table then use as below. In my case i have used this way:
writer.Write("<tr><td><table width='100%' border='0' cellSpacing='0' cellPadding='0'><tr class='ms-WPHeader'><td align='left' class='ms-wpTdSpace'></td><td class='ms-WPHeaderTd'><h3 class='ms-standardheader ms-WPTitle' style='text-align:justify;'><nobr><span>" + productCategory + " </span></nobr></h3></td><td align='right' class='ms-WPHeaderTdMenu'></td><td class='ms-WPHeaderTdSelection'></td><td align='left' class='ms-wpTdSpace'></td></tr></table></td></tr>");

No comments:

Post a Comment