将url参数添加到asp主题文件夹中的css文件中
我编写了一些有助于 js 文件版本控制的代码。本质上,它围绕当前脚本管理器旋转,并附加 javascript 文件路径和文件的 md5 哈希值。所以
<script src="../Javascript/Navigation.js" type="text/javascript"></script>
我
<script src="../Javascript/Navigation.js?md5=70D2B4D1F236C7E340D9152B9E4102C3" type="text/javascript"></script>
认为这是一件相当常见的事情(或其变体)。我正在努力做的是拿起 app_themes 文件夹中的 css 文件并执行相同的操作。
如何进入并更改 css 链接?
I have written a bit of code that helps with versioning of js files. Essentially it spins around the current script manager and appends the javascript file path with an md5 hash of the file. So
<script src="../Javascript/Navigation.js" type="text/javascript"></script>
becomes
<script src="../Javascript/Navigation.js?md5=70D2B4D1F236C7E340D9152B9E4102C3" type="text/javascript"></script>
I think this is a fairly common thing to do (or variants of it). What I am struggling to do is pick up the css files in the app_themes folder and do the same.
How do I get in and change the css links?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用控件适配器将此行为巧妙地注入到页面中,如下所示:
您可以通过将以下内容保存为 App_Browsers 文件夹中的 *.browser 文件来插入它:
总的来说,我认为控件适配器是一种强大的类似AOP的机制,用于将行为注入到控件/页面生命周期中;它们几乎被完全忽略,而倾向于传统的子分类。
You can use a control adapter to neatly inject this behavior into the page as follows:
You can plug it in by saving the following as a *.browser file in the App_Browsers folder:
Overall, I think Control Adapters are a powerful AOP-like mechanism for injecting behavior into control/page life-cycles; they are almost entirely ignored in favor of traditional sub-classing.
我面临一个问题,即每次回发时都会在 html 标记中重复 css 条目。
例如,我有 newabc.css。该代码会将其更改为 newabc.css?v=1。如果我在 5 次回发后看到 html 源,它将有 5 个“newabc.css?v=1”。所以我添加了 link.EnableViewState = False,它工作正常,但实际上需要吗?
I am facing one issue that it is repeating css entry in html markup on every postback.
for example, I have newabc.css. the code will change it to newabc.css?v=1. if I see html source after 5 postback, it will have 5 "newabc.css?v=1". so I added link.EnableViewState = False, it works fine but is it actually needed?
使用 Combres 来避免重复发明轮子。满足您要求的一切,甚至更多!
Avoid to invent the wheel twice by using Combres instead. Does everything you ask for, and more!