Purpose is to add the css file in the page through webpart.
So in the Create child control method of the webpart , create the object of the css and then insert in the header control of the page.Once this is done we can attach the css to any control.
Follow this sample code for the same.
protected override void CreateChildControls()
{
try
{
base.CreateChildControls();
Microsoft.SharePoint.WebControls.CssLink cssLink = new Microsoft.SharePoint.WebControls.CssLink();
cssLink.DefaultUrl = "/_layouts/1033/styles/Tab.css";
this.Page.Header.Controls.Add(cssLink);
}
Place the css file at the specified folder location and then create the object for the css and then add this object of css file in the page.
Now you can use the css classes in the controls.
Enjoy!!!
No comments:
Post a Comment