User controls inside an UpdatePanel - css styles are gone when updating (IE8)

后端 未结 4 1638
忘掉有多难
忘掉有多难 2021-01-19 14:58

I have an user control inside an UpdatePanel. Once an event is triggered and updates the user control - it seems to lose its css styles. This happened to me in IE8 only, whi

4条回答
  •  [愿得一人]
    2021-01-19 15:57

    This issue is mentioned here.

    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("", ResolveUrl(CssClassFile));
             ScriptManager.RegisterClientScriptBlock(this, typeof(MyBlahControl), "MyBlahId", css, false);
        }
     }
    

提交回复
热议问题