ASP.NET 2.0 with the use of the Master Page CSS Optimization Model

Related Tags:

  ASP.NET 2.0 with the use of the Master Page css Optimization Model 

  ASP.NET 2.0 has been added to the built-in MasterPage the support of this for us is a great convenience.    However, after a period of use, I found MasterPage not so perfect: nested MasterPage can not support the design of the interface, as well as to refer to the following Content Page CSS increase in the problem. 

  Usually, in the absence of 2.0, we have to increase the page, a quote CSS Syntax is as follows: 

  <link Rel="stylesheet" href="css/test.css" /> 
  Originally that it is common practice.    But in a MasterPage sub-pages, there has been a very embarrassing situation, and that is: we incorporate the code into what position? 
  MasterPage because of the specific content of the page, only one definition of <asp: Content /> label content.    We accordance with the usual practice in the inside unable to aspx page <header /> content control.    This <link /> labels also must be placed on <header /> within.    I tested In "asp: Content /> internal join the lines of code, but will be prompted to go wrong. 
  At the same time, we can not in the MasterPage <header /> internal ContentPlaceHolder put away for a future Add to the application of CSS code. 
  So my approach is the definition of a helper category are as follows: 

  Static public class ControlHelper 
  ( 
  Static public void AddStyleSheet (Page page, string cssPath) 
  ( 
  HtmlLink link = new HtmlLink (); 
  Link.Href = cssPath; 
  Link.Attributes [ "rel"] = "stylesheet"; 
  Link.Attributes [ "type"] = "text / css"; 
  Page.Header.Controls.Add (link); 
  ) 
  ) 
  Thus, in specific pages, we can add the following code CSS quote: 

  Protected void Page_Load (object sender, EventArgs e) 
  ( 
  ControlHelper.AddStyleSheet (this.Page, "css / projectPage.css"); 
  ) 
  Furthermore, this code to support the specific contents page, or a nested used in the Master Page. 

  Here Some people may ask, why should such a separate CSS to load?    Necessary?    I put all the pages to the definition of several public CSS CSS document is not very good? 

  In fact, familiar with the standard html web production friends will be aware that in the relatively perfect state, and html page for the performance of a complete separation CSS.    And our web-based design standards, is usually first to make a Master Page of all the positioning framework div code, as well as header, footer part of the modified code.    These are the contents of each page should be used, will be placed at the inside of a unified CSS.    Other specific content pages, and each page will be different layout of the contents of the modified format, and I therefore specific to each specific page on the part of its own in the CSS.    This will form a Master Page in accordance with the realization level (nested), the merger of the CSS layer model.    Its benefits are achieved in each of the CSS document separation of duties, but also easy to understand and maintain. 

  As soon contact ASP.NET 2.0, the above is only explored by the personal experience that small, if more convenient solutions, please friends exhibitions. 


Related articles:

Rookie of using Dreamweaver MX 2004 act (8) to open a browser window
  Original content of this site, please specify the source of reproduced I love DivCSS.    Show - hidden layers    "Show - hidden layers" moves, hidden or restore one or more of the default visibility.    This action on the user's page with an inte...
Website using Dreamweaver MX batch update
  In Dreamweaver 4.0, we had contact with the concept of the template and know their style is similar quantities generated web tool.    Now in Dreamweaver MX (hereinafter referred to DW MX), the function of the template and has been further refined and strengthened, in particular for ...
Web2.0 the crux of the matter is the integration of
  Am writing on the "social business" BLOG, some of their hidden thoughts on web2.0 dug out.    Web2.0 now, there is a confusion, I do not know whether there are others, but I really feel.    That is, "large and comprehensive" or "small but excelle...
Flash derived from the background transparent GIF animation
  One day, the emergency users: Flash, set up a small animation, but to become the GIF format with a white background, I would like to ask whether the Flash in the background as a transparent, GIF plans to export without background?    In fact, using Flash MX, in its "publish set...
Using Fireworks MX completion of a work of calligraphy
  Remember in elementary school, we always some extra-curricular elective course, I take the calligraphy.    At that time, under the guidance of teachers in the use of the sticks were stained with the ink on white rice paper in the brush to complete their work at.    Heart i...