开发者

ASCX controls losing style?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜