当我尝试在网页中使用更新面板时,CSS不起作用

CSS not working when am trying to use update panel in my webpage?

本文关键字:更新 不起作用 CSS 网页      更新时间:2024-03-24

我有包含css的主页面。。。当我在内容占位符中添加更新面板时,母版页上的css运行良好,但内容占位符中的css不运行。

<%@ Page Title="District Master" Language="C#" MasterPageFile="~/webpages/MasterPage_new.master"
    AutoEventWireup="true" CodeFile="frmDistrict.aspx.cs" Inherits="webpages_frmDistrict" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager2" EnablePartialRendering="true" runat="server">
    </asp:ScriptManager>
    <div id="main_div">
        <asp:UpdatePanel ID="uppnl" runat="server" Mode="Conditional">
            <ContentTemplate>
                <table style="width: 100%; float: left;">
                    <tr>
                        <td style="height: 100px; width: 100%; float: left;">
                            <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
                            <asp:Button ID="btnSearchOK" runat="server" Text="Ok" Font-Names="Verdana" Font-Size="11px"
                                Width="6%" Font-Bold="True" OnClick="btnSearchOK_OnClick" />
                            <asp:Button ID="btnRefresh" runat="server" Text="Refresh" Font-Names="Verdana" Font-Size="11px"
                                Width="11%" Font-Bold="True" OnClick="btnRefresh_OnClick" />
                            <asp:Button ID="btnClose" runat="server" Text="Close" Font-Names="Verdana" Font-Size="11px"
                                Width="9%" Font-Bold="True" OnClick="btnClose_OnClick" />
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>

这是因为ASP.NET更改了内容面板中所有元素的id,并将主控形状的名称(如id="content"将变为id="body#content")作为前缀。若要进行验证,请检查浏览器中的"查看源代码"。

解决方案是根据生成的ID s更新CSS。