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

后端 未结 3 1164
再見小時候
再見小時候 2021-02-11 15:46

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

3条回答
  •  遇见更好的自我
    2021-02-11 16:31

    An update panel can render as a div or span (depending on mode). Easiest way to achieve what you want is to wrap the UpdatePanel in a standard Panel:

    
        
        
    
    

    The you can just do this in codebehind:

    Panel1.CssClass = "myCssClass";
    

    You could also use a div, like LFSR Consulting said, and add runat="server" and then change the class attribute. But Panel is a bit easier to work with (a Panel just renders as a div).

提交回复
热议问题