How can I add a css class to an updatepanel in ASP.Net?

后端 未结 2 1642
粉色の甜心
粉色の甜心 2021-02-11 16:00

How can I add a css class to an updatepanel in the c# code behind file of asp.net

相关标签:
2条回答
  • 2021-02-11 16:28

    As you've seen the update panel doesn't have a css class property. So since it can't be done directly you need a work around; there are two (Grabbed from UpdatePanel and CSS) that can get the behavior you desire.

    One is to surround the update panel with a div:

    <div id="foo" style="visibility: hidden; position: absolute">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        </asp:UpdatePanel>
    </div>
    

    The other is to apply a css selector based on the update panel's id:

    <style type="text/css">
    #<%=UpdatePanel1.ClientID%> {
        visibility: hidden;
        position: absolute;
    }
    </style>
    

    Yet another way not mentioned in the article is surround the panel in a div and style the update panel based on it rendering as a div:

    <style type="text/css">
    #foo div {
        visibility: hidden;
        position: absolute;
    }
    </style>
    
    <div id="foo">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        </asp:UpdatePanel>
    </div>
    
    0 讨论(0)
  • 2021-02-11 16:41

    you can use single class html attribute

     <asp:UpdatePanel ID="UpdatePanel1" runat="server" class="MyCssClass">
     </asp:UpdatePanel>
    
    0 讨论(0)
提交回复
热议问题