1

I am trying to use custom CSS in a Visual Web Part. CSS file is in Style library like

http://mysite:7/Style%20Library/SnehamCss.css

Now in Visual Web Part I am trying to register this using

<SharePoint:CssRegistration Name="/Style Library/SnehamCss.css" runat="server"></SharePoint:CssRegistration>,

At the end Visual Web part isn't rendering using the css defined in file. I have tried to follow many blogs but its not helping.

3 Answers 3

3

You can use the Layout mapped folder then use the SharePoint:CssRegistration in this way:

<SharePoint:CssRegistration ID="CssRegistration1" Name="/_layout/SnehamCss.css" runat="server"></SharePoint:CssRegistration>

You can see here for more details.

Sign up to request clarification or add additional context in comments.

Comments

0

Try to add After="corev4.css":

<SharePoint:CssRegistration Name="/Style Library/SnehamCss.css" After="corev4.css" runat="server"></SharePoint:CssRegistration>

Comments

0

In the .ascx file of the web part control add

<link href="../../../_layouts/MyVisualWebParts/myStyleForWebPart.css" rel="stylesheet" type="text/css" />

If you have mapped the Layouts folder then create your css file there. Then drag the CSS file from the Solution explorer onto the .ascx file. This automatically create the Link tag.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.