用户控件调用外联:
public partial class DropDownSelect : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Page.Header.Controls.Add(new LiteralControl("<link href=/"WOODY-WU.css/" type=/"text/css/" rel=/"stylesheet/" />"));
}
}
}
本文介绍了一个ASP.NET用户控件如何在页面加载时动态添加外部CSS文件的方法。通过在用户控件的Page_Load事件中使用Page.Header.Controls.Add方法,可以实现将指定的CSS文件链接到当前页面。

被折叠的 条评论
为什么被折叠?



