简体   繁体   English

CSS中的JavaScript在回发时丢失(ASP.NET)

[英]JavaScript in CSS lost on postback (ASP.NET)

I am using the library 'CSS3 Pie' to allow me to use border-radius with previous IE a treat, by having the CSS style for the element like this: 我正在使用“ CSS3 Pie”库,以使元素具有如下样式的CSS样式,从而可以对以前的IE使用border-radius:

border: 1px solid #122541;
border-radius: 8px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
behaviour: url('../Content/Scripts/PIE.htc');

It works a treat, however when the page is postback (I am using an UpdatePanel if that makes any difference), the JS in PIE.htc that allows border-radius to work, doesn't fire so in previous IE versions the corners go back to being square. 它可以工作,但是当页面回发时(如果有任何区别,我将使用UpdatePanel),PIE.htc中允许边界半径工作的JS不会触发,因此在以前的IE版本中,死角会变回到正方。

What can I put in my Page_Load to essentially 'refire' the CSS on postback? 我可以在Page_Load中放些什么,以便在回发时实质上“重新激发” CSS? Or is there another fix? 还是有其他解决方法?

您可能会使用PIE的JS版本(链接: http : //css3pie.com/documentation/pie-js/ ),并在回发时调用如下脚本:

  Page.ClientScript.RegisterStartupScript(GetType(), "myScriptName", "<script>if (window.PIE) {$('.rounded').each(function() {PIE.attach(this);});}</script>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM