使用更新面板时,服务器控件丢失了CSS样式

我正在为我的项目使用此模板。 我在表单和更新面板中使用了updatepanel,我采用了不同的asp.net下拉列表控件。 现在的问题是当页面回复时,css样式适用于下拉列表丢失…因为我对CSS没有详细的想法..所以请帮助

现在有2种可能性

  • 根本不要将css应用于下拉列表
  • 在回发后将CSS应用于下拉列表

如果我只是将下拉控件拖放到表单,则下拉列表会显示css。

我也使用了这个的主页…我不想将css应用于下拉列表…该怎么做..请建议我…

页面加载时的图像

在此处输入图像描述

回发后的图像(如果使用updatepanel) 在此处输入图像描述

.aspx代码

 





Chapter details <asp:Label ID="Label1" runat="server" Text=''> <asp:Label ID="Label2" runat="server" Text=''> <asp:Label ID="Label3" runat="server" Text=''> <asp:Label ID="Label4" runat="server" Text=''> <asp:Label ID="Label5" runat="server" Text=''> <asp:Label ID="Label6" runat="server" Text=''> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandArgument='' Text="Edit" CommandName="EditDetails"> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandArgument='' Text="Delete" CommandName="DeleteDetails" OnClientClick="if (!window.confirm('Are you sure you want to delete this item?')) return false;">

您可以在OnInit event注册您的CSS

 string cssLocalisation = string.Format("", ResolveUrl(YourFile)); protected override void OnInit(EventArgs e) { base.OnInit(e); var scriptManager = ScriptManager.GetCurrent(Page); if ( ! scriptManager.IsInAsyncPostBack) { ScriptManager.RegisterClientScriptBlock(this, typeof(YourControl), "YourKey", cssLocalisation, false); } }