本文介绍了有一个ClientScriptManager.RegisterClientScriptInclude等效的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法可让您注册JavaScript

The ClientScriptManager.RegisterClientScriptInclude method allows you to register a JavaScript reference with the Page object (checking for duplicates).

对于CSS引用,是否有等价的此方法?

Is there an equivalent of this method for CSS references?

类似问题适用于和 ClientScriptManager.RegisterClientScriptResource

推荐答案

简短答案:不。你可以自定义自己的功能(如CMPalmer所建议的),以接收CSS嵌入资源(如Gulzar建议的)并将其嵌入页面。

Short answer: no. You could certainly roll your own functions (as CMPalmer suggests) to take CSS embedded resources (as Gulzar suggests) and embed them on the page.

作为最佳实践,但我不知道你为什么要这样做。如果你正在制作一个具有很多CSS样式的可重用控件,我的建议是将类名硬编码到控件的符合标准的输出中,并发送带有建议样式表的控件。这样,您的用户/客户就可以覆盖您的建议样式以满足他们的需求,并且通常允许他们根据自己的需要管理其CSS设置。

As a best-practice matter, though, I'm not sure why you would want to do this. If you're making a reusable control that has a lot of CSS styling, my advice would be to just hard-code the class names into the standards-compliant output of your control, and ship the control accompanied by a suggested stylesheet. This gives your users/customers the option of overriding your suggested styles to fit their needs, and in general allows them to manage their CSS setup as they see fit.

将标记与标记分离是一件好事 - 您已经在避开各种内置ASP.NET风格属性的正确路径上,但您应该它一直和保持CSS出你的.dll。

Separating style from markup is a Good Thing - you're already headed down the right path in avoiding the various built-in ASP.NET style attributes, but you should take it all the way and keep the CSS out of your .dll.

这篇关于有一个ClientScriptManager.RegisterClientScriptInclude等效的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 09:36