4

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!

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I'll check into that. Thank you.
Cheers, also related though I don't like the way he used: stackoverflow.com/questions/2366605/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.