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 also 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.RegisterClientScriptBlockto include them after checking if already included byPage.ClientScript.IsClientScriptBlockRegisteredgiving it the unique key used in the Register method.Either way, you’ll have to remove the CSS includes from the
.aspxitself and put it in the code behind.