LiteralControl 控件实现动态添加CSS

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CommonQuery_PageRegStyle:System.Web.UI.Page
{
protectedstringstrAlert="Hello,HappyNewYear!";
protectedvoidPage_Load(objectsender,EventArgse)
{

}

protectedoverridevoidOnPreRender(EventArgse)
{

stringcssFrageMent="<styletype='text/css'>"
+".CommonQueryBtn{"
+"border:0;width:64px;height:20px;background:url('"
+HttpRuntime.AppDomainAppVirtualPath+@"/images/BUTTON/btn.jpg');"
+"}</style>";
LiteralControlinclude
=newLiteralControl(cssFrageMent);
this.Page.Header.Controls.Add(include);
base.OnPreRender(e);
}

}

你可能感兴趣的:(UI,Web,css,Security)