I want to conditionally associate a CSS file base with a user role. The administrator should link my admin.css file, while everyone else (other roles and anonymous users) should display my global.css file. It can be done?
Try this :
protected void Page_Init(object sender, EventArgs e) { HtmlLink css = new HtmlLink(); // add conditional logic to add correct css file css.Href = "css/fancyforms.css"; css.Attributes["rel"] = "stylesheet"; css.Attributes["type"] = "text/css"; css.Attributes["media"] = "all"; Page.Header.Controls.Add(css); }
Either you can create a theme based on the role - AdminTheme (will contain admin.css) and GlobalTheme (will contain global.css), or you can dynamically write the element <link>in the tag <head>after providing the runat = "Server" attribute.
<link>
<head>
PreInit Init .
, <head>, if , " ", <link> ( @import), , CSS).
@import
, HtmlGenericControl , , .
/// , , " ", css , , , .
- . , Opera/Firefox, , , " ". , , css , .
Source: https://habr.com/ru/post/1706474/More articles:How to count the number of lines in a large CSV file using Perl? - perlWebPart Security - sharepointUnable to insert string into MySQL text table - syntaxDatabase transfers: manage using build script or automatically when application starts? - build-processCompare the text of the two methods - diffdollar sign in javascript methods - javascriptUsing Visio to Generate MySQL DDL - mysqlI find using a session object (.net) an evil practice, am I too harsh? - asp.netWhy am I getting the error "Only antlib URLs can be located only from a URI, not a URI" when I try to run the hibernation tools in my build.xml file - hibernateHow to get the total number of lines before reading in a large file in PHP - phpAll Articles