I'm stepping in to a project that has been going on for a few years. One of the issues I saw immediately is that CSS files are being included in the master pages, the aspx pages, user controls and more, and als开发者_如何学JAVAo style sheets are created and imporeted via aspx files, and not linked. (A mess, I know) It becomes impossible to debug styling issues.
What would be the best strategy for removing the double imports? Is there any built-in method to insure files are imported only once?
Thank you!
One way will be to have all CSS files embedded as resources then use Page.ClientScript.RegisterClientScriptResource.
Another way is leave the files as they are now and use Page.ClientScript.RegisterClientScriptBlock
to include them after checking if already included by Page.ClientScript.IsClientScriptBlockRegistered
giving it the unique key used in the Register method.
Either way, you'll have to remove the CSS includes from the .aspx
itself and put it in the code behind.
精彩评论