ASCX 操控失去风格?
我有一个基于 ASCX 的项目,在 IE7 中有时似乎失去了 CSS 样式。每隔一段时间,ASCX 的某些部分就会突然不渲染任何样式来保持信息行的检查。这种情况的发生不一致。一天只需要2到3次左右。我不能总是重现该问题,但我需要解决该问题。 ASCX 控件的其余部分以及页面的其余部分仍然保留其样式。我可以添加一些东西来强制控件始终呈现 CSS 吗?
I have an ASCX based project that in IE7 sometimes seems to lose the CSS styling. Every once in a while, parts of the ASCX suddenly render no styling to keep the rows of information in check. This happens inconsistently. Only about 2 to 3 times a day. I cannot always reproduce the issue, but I need to fix the issue. The rest of the ASCX controls still keep their styles, as well as the rest of the pages. Is there something that I can add to force the controls to always render the CSS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为吉姆在这里有所作为。我怀疑您的样式嵌入在控件中,并且它的某些部分未包含在回发中,这会“孤立”样式 - 控件的元素不会定义 CSS。
一个简单的测试是获取控件中的任何 CSS 并将其放入其所使用的页面的 HEAD 中。这应该可以修复它,然后您可以将其全部移至其自己的 .css 文件中。
我们已经创建了像脚本一样注册 CSS 的 ASP.NET 页面扩展方法,并且每个控件都注册它需要呈现的 CSS 文件。许多控件使用相同的 CSS,因此相同的“我之前包含过这个吗?”脚本逻辑也适用于 CSS。
Viola - 我们的控件中不再缺少 CSS。
I think Jim is on to something here. I suspect your styling is embedded in the control and some portion of it is not included in a post-back which would 'orphan' the styling - elements of the control would not have the CSS defined.
An easy test would be to take any CSS you have in the control and put it in the HEAD of the page it's used on. That should fix it, and then you can move it all off into its own .css file.
We've gone so far as to create ASP.NET Page Extension methods that register CSS like script, and each control registers the CSS file(s) it needs to render. Many controls use the same CSS so the same 'have I included this before?' logic for scripting works for CSS too.
Viola - no more missing CSS in our controls.