I have ascx in which there is CSS ... Is this considered bad practice?
Yes. Your CSS rules should ideally be defined in a separate static css file that only loads once in the header of your main page. CSS in the body is not up to standard.
If you configure the correct caching rules in your static CSS files, this will significantly reduce the amount of data that you pull on the cable, because CSS rules should not be loaded again for each page load. If you want to include this file only in the header, if some dependent ASCX files are displayed, see Neal Fenwick 's answer .
Update
For some reason, Neil Fenwick seems to have deleted his answer. I hope he does not mind me reproducing it here:
Definitely YES, it's possible.
I would recommend looking at a library like ClientDependency to manage your CSS and JS applications and dependencies.
Good examples of how to include the data listed on the CodeLix ClientDependency page. Organizing CSS and JS dependencies is a good practice, so you can repeatedly state your requirement, but only exit the dependency once.
source share