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

后端 未结 4 1640
忘掉有多难
忘掉有多难 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:33

    I had the same issue with my application, it seemed to kill all styling in my dynamic panel... I corrected it by moving the content placeholder (place I write the dynamic HTML to) into the < head> tag on my master page.

    Working! Thank you all :)

    0 讨论(0)
  • 2021-01-19 15:41

    Copy the css from user control to the page will solve it.

    0 讨论(0)
  • 2021-01-19 15:53

    I had similar problem.
    I solved it moving css <link .. from the <page> to the <header>.

    Since I use a MasterPage and I don't want the link in all pages, I found useful putting a ContentPlaceHolder in the MasterPage's Header

    <head id="Head1" runat="server">
      ...
      <asp:ContentPlaceHolder ID="HeaderContentPlaceHolder" runat="server"/>
    </head>
    

    and then the link inside the desired page:

    <asp:Content ID="Content2" ContentPlaceHolderID="HeaderContentPlaceHolder"       Runat="Server">
        <link rel="stylesheet" type="text/css" href="CSS/my.css" />
    </asp:Content> 
    
    0 讨论(0)
  • 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("<link rel=\"stylesheet\" href=\"{0}\" type=\"text/css\" />", ResolveUrl(CssClassFile));
             ScriptManager.RegisterClientScriptBlock(this, typeof(MyBlahControl), "MyBlahId", css, false);
        }
     }
    
    0 讨论(0)
提交回复
热议问题