Пример #1
0
        /// <summary>
        /// 往页面中写入css样式
        /// </summary>
        /// <param name="htmlHelper">需要扩展对象</param>
        /// <param name="cssFiles">文件路径</param>
        /// <returns></returns>
        public static MvcHtmlString AppendCssFile(this HtmlHelper htmlHelper, params string[] cssFiles)
        {
            string cssFile = "";

            foreach (string file in cssFiles)
            {
                if (cssFile != "")
                {
                    cssFile += ",";
                }
                cssFile += file;
            }
            string cssStr = CssHelper.ReadCssFile(cssFiles);


            StringBuilder content   = new StringBuilder();
            string        cssFormat = "<style>{0}</style>";

            content.AppendFormat(cssFormat, cssStr);
            return(new MvcHtmlString(content.ToString()));
        }