Aug 21

Ajouter votre css dans le projet. Changer la l’action de compilation (Build action) en « Embeded Resource » :

Ajouter votre ressource dans « AssemblyInfo.cs » (répertoire « Properties » du projet) par la ligne de commande suivante :

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

À noter le perform subsitution à true qui va permettre à la css de retrouver les images se trouvant égualement dans les resource.

Ajout des fichiers images dans la resource :

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

Exemple de css avec lien d’image:

/*************************************************************************************************/ 
/* 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; 
} 

Ensuite il faut ajouter le css dans la page du control:

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);
}
Tags:

Comments

Slim Fit Blog

Posted on Wednesday, 18 March 2009 05:50

this is a same way i done also, nice writings

Helori

Posted on Wednesday, 18 March 2009 10:32

Thanks! I will translate the post in english.

Add comment




  Country flag

biuquote
Loading