- Using Visual Studio 2010, open your Visual Web Part solution
- In Solution Explorer, right-click on the project and select Add -> SharePoint "Layouts" Mapped Folder
- Right-click on the newly created Layouts folder and select Add -> New Folder
- Edit the name from "NewFolder1" to "1033"
- Right-click on the "1033" folder and select Add -> New Folder
- Edit the name from "NewFolder1" to "Styles"
- Right-click on the "Styles" folder and select Add -> New Folder
- Edit the name from "NewFolder1" to the name of your Project (i.e. MyProject in this example)
- Right-click on the "MyProject" folder and select Add -> New Item...
- Under the Installed Templates section, expand Visual C# and click on Web
- Click on the Style Sheet icon, update the name of your style sheet (i.e. Standard.css in this example), and click Add
- You may now enter the appropriate style sheet rules in this file and save the changes
During the deployment of your Visual Web Part, the custom style sheet will be deployed directly to the SharePoint farm under the following location on the web front end servers: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES\MyProject.
Now, to reference the style sheet in your Visual Web Part, you may do so via the following steps:
Now, to reference the style sheet in your Visual Web Part, you may do so via the following steps:
- Open your Visual Web Parts .ascx file
- After the "<%@ Control" tag, add the following line: <SharePoint:CssLink ID="cssLink1" runat="server" DefaultUrl="MyProject/Standard.css" />
- Save the change
At this point, you will be able to reference the new style sheet within the controls on your .ascx page.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.