我怎么能一个CSS类添加到ASP.Net一个UpdatePanel? [英] How can I add a css class to an updatepanel in ASP.Net?

查看:103
本文介绍了我怎么能一个CSS类添加到ASP.Net一个UpdatePanel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在C#代码CSS类添加到一个UpdatePanel背后asp.net

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

推荐答案

文件正如你见过更新面板没有一个CSS类属性。那么既然不能直接做你需要周围的工作;有两个(从的UpdatePanel和CSS 抢下),可以。得到你想要的行为

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.

一是围绕用一个div更新面板:

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>



另一种是应用基于更新面板的ID的CSS选择器:

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>



另一种方式在文章中没有提到的是环绕面板的div和风格基于更新面板它呈现为一个div:

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>

这篇关于我怎么能一个CSS类添加到ASP.Net一个UpdatePanel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆