且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

UpdatePanel 中的用户控件 - 更新时 css 样式消失(IE8)

更新时间:2023-02-22 11:07:06

提到这个问题这里.

我尝试了这个建议 - 在 OnInit 中注册 css 链接 - 它似乎有效.

I tried the suggestion - registering the css link in the OnInit - and it seems to work.

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    ScriptManager sm = ScriptManager.GetCurrent(Page);
    if (!sm.IsInAsyncPostBack)
    {
         string css = string.Format("<link rel="stylesheet" href="{0}" type="text/css" />", ResolveUrl(CssClassFile));
         ScriptManager.RegisterClientScriptBlock(this, typeof(MyBlahControl), "MyBlahId", css, false);
    }
 }