HtmlGenericControl 创建服务器端控件

         ////创建服务器端控件.
        ////指定的标记"LINK"初始化此类的新实例.
        HtmlGenericControl objLink = new HtmlGenericControl("LINK");
        objLink.ID = ID;
        objLink.Attributes["rel"] = "stylesheet";
        objLink.Attributes["type"] = "text/css";
        objLink.Attributes["href"] = "css/indexcss.css";

        ////此控件不产生任何可见输出,仅作为其他控件的容器,可在其中添加,插入或移除控件.
        Page.Controls.Add(objLink);

在别人的blog上看到的,所以自已拿来用了一下,自己可以扩展一下动态调用CSS应用。

原文地址:https://www.cnblogs.com/yhongl/p/3937941.html