Пример #1
0
        public static MvcHtmlString Script(this HtmlHelper src, string scriptName, bool isExternal = false)
        {
            var tag = new TagBuilder("script");
            tag.Attributes.Add("type", "text/javascript");
            if(isExternal)
            {
                tag.Attributes.Add("src", scriptName);
            }
            else
            {
                var urlHelper = new UrlHelper(src.ViewContext.RequestContext);
                tag.Attributes.Add("src", urlHelper.Content("~/Content/Scripts/" + scriptName));
            }

            return tag.GetMvcHtmlString();
        }
Пример #2
0
        public static MvcHtmlString Style(this HtmlHelper src, string styleSheetName, bool isExternal = false)
        {
            var tag = new TagBuilder("link");
            tag.Attributes.Add("type", "text/css");
            tag.Attributes.Add("rel", "stylesheet");
            if(isExternal)
            {
                tag.Attributes.Add("href", styleSheetName);
            }
            else
            {
                var urlHelper = new UrlHelper(src.ViewContext.RequestContext);
                tag.Attributes.Add("href", urlHelper.Content("~/Content/Styles/" + styleSheetName));
            }

            return tag.GetMvcHtmlString();
        }