Mar 20

Add your style sheet (CSS) in the project. Change the build action to "Embedded resource":

032009_1716_AddingaCSSW1

Register your resource in "AssemblyInfo.cs" ("Properties" folder) using the following command line:

[assembly: WebResource("NotesFor.UI.Themes.Default.ActionBar.css", "text-css", PerformSubstitution=true)] 

Note that you have to put perform substitution to true to allow the CSS to retrieve images that are also web resources.

Register the image files as resource:

[assembly: WebResource("NotesFor.UI.Themes.Default.nav-over.png", "image/png")] 
[assembly: WebResource("NotesFor.UI.Themes.Default.nav.png", "image/png")] 

 

Sample CSS with an image link:

/*************************************************************************************************/ 
/* Action bar                                                                                    */ 
/*************************************************************************************************/ 

.action-bar 
{ 
      padding: 0px 0px 0px 0px; 
      height: 25px; 
      line-height: 25px; 
      vertical-align: middle; 
      background-color: #C8C8C8; 
      margin: 0; 
      background-image: url('<%=WebResource("NotesFor.UI.Themes.Blue.nav.png")%>'); 
} 

.action-bar ul 
{ 
      margin: 1; 
      padding: 0; 
      display: inline; 
      float: left; 
} 

.action-bar li 
{ 
      display: block; 
      float: left; 
      height: 25px; 
      line-height: 25px; 
      width: 75px; 
      text-align: center; 
      vertical-align: middle; 
      border-right: 1px solid #2C3642; 
      text-transform: uppercase; 
      font-weight: bold; 
      font-family: verdana; 
      font-size: 11px; 
} 

.action-bar li a:link, .action-bar li a:visited 
{ 
      text-decoration: none; 
      height: 25px; 
      line-height: 25px; 
      width: 75px; 
} 

.disabled, .disabled a:link, .disabled a:visited, .disabled a:hover 
{ 
      color: #C0C0C0; 
      text-decoration: none; 
      background-image: url('<%=WebResource("NotesFor.UI.Themes.Blue.nav-over.png")%>'); 
} 

.enabled, .enabled a:link, .enabled a:visited 
{ 
      color: #333333; 
      text-decoration: none; 
}

.enabled a:hover, .enabled a.selected 
{ 
      color: #A1FFFF; 
      text-decoration: none; 
} 

.disabled a.selected 
{ 
      color: #A1FFFF; 
      text-decoration: none; 
} 

 

Finally, you have to add the CSS in control page:

protected override void OnInit(EventArgs e) 
{ 
	string cssUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(),NotesFor.UI.Themes.Default.ActionBar.css); 
	HtmlLink cssLink = new HtmlLink(); 
	cssLink.Href = cssUrl;
	cssLink.Attributes.Add("rel", "stylesheet"); 
	cssLink.Attributes.Add("type", "text/css"); 
	this.Page.Header.Controls.Add(cssLink); 
} 

 

Sample code:

WebReource.zip (892.85 kb)

Tags:

Comments

Team Building Company

Posted on Friday, 23 April 2010 06:33

How do you set up style sheets in the first place, is there a special program you need?

Comments are closed