示例#1
0
        internal static string GetWebResourceUrl(Page owner, Type type, string resourceName, bool htmlEncoded, IScriptManager scriptManager)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (string.IsNullOrEmpty(resourceName))
            {
                throw new ArgumentNullException("resourceName");
            }
            if ((owner == null) || !owner.DesignMode)
            {
                return(AssemblyResourceLoader.GetWebResourceUrl(type, resourceName, htmlEncoded, scriptManager));
            }
            ISite site = owner.Site;

            if (site != null)
            {
                IResourceUrlGenerator service = site.GetService(typeof(IResourceUrlGenerator)) as IResourceUrlGenerator;
                if (service != null)
                {
                    return(service.GetResourceUrl(type, resourceName));
                }
            }
            return(resourceName);
        }
示例#2
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (DesignMode)
            {
                IServiceProvider serviceProvider = (IServiceProvider)this.Site;

                IResourceUrlGenerator urlGenerator = (IResourceUrlGenerator)serviceProvider.GetService(typeof(IResourceUrlGenerator));

                writer.WriteBeginTag("div");
                writer.Write(" style=\"");

                if (urlGenerator != null)
                {
                    writer.WriteStyleAttribute("background-image", "url('" + urlGenerator.GetResourceUrl(this.GetType(),
                                                                                                         "Aurigma.GraphicsMill.AjaxControls.Resources.Background.gif") + "');");
                }

                writer.WriteStyleAttribute("background-position", "bottom");
                writer.WriteStyleAttribute("background-repeat", "repeat-x");
                writer.WriteStyleAttribute("background-color", "#FFFFFF");
                writer.WriteStyleAttribute("color", "#444444");
                writer.WriteStyleAttribute("font", "messagebox");
                writer.WriteStyleAttribute("border", "1px solid #CCCCCC");
                writer.WriteStyleAttribute("padding", "4px 4px 0px 4px");
                writer.WriteStyleAttribute("left", this.Style["LEFT"]);
                writer.WriteStyleAttribute("top", this.Style["TOP"]);
                writer.WriteStyleAttribute("position", this.Style["POSITION"]);
                writer.Write("\"");

                writer.Write(HtmlTextWriter.TagRightChar);
                if (urlGenerator != null)
                {
                    writer.WriteBeginTag("img");
                    writer.WriteAttribute("width", "16");
                    writer.WriteAttribute("height", "16");
                    writer.WriteAttribute("align", "middle");
                    writer.WriteAttribute("src", urlGenerator.GetResourceUrl(this.GetType(),
                                                                             "Aurigma.GraphicsMill.AjaxControls.Resources." + this.GetType().Name + ".gif"));
                    writer.Write(" ");
                    writer.Write(HtmlTextWriter.SelfClosingTagEnd);
                }
                writer.Write("&nbsp;<b>");
                writer.Write(this.GetType().Name);
                writer.Write("</b>&nbsp;-&nbsp;");
                writer.Write(ID);
                writer.WriteEndTag("div");
            }
            else
            {
                writer.WriteBeginTag("span");
                writer.WriteAttribute("id", ClientID);
                writer.WriteAttribute("style", "display:none;");
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.WriteEndTag("span");
            }

            base.Render(writer);
        }
示例#3
0
        public string GetWebResourceUrl(string webResourceName)
        {
            IServiceProvider serviceProvider = this.Component.Site;
            string           result          = string.Empty;

            if (serviceProvider != null)
            {
                IResourceUrlGenerator urlGenerator =
                    (IResourceUrlGenerator)serviceProvider.GetService(typeof(IResourceUrlGenerator));
                if (urlGenerator != null)
                {
                    result = urlGenerator.GetResourceUrl(this.Component.GetType(), webResourceName);
                }
            }
            return(result);
        }
示例#4
0
        /// <summary>
        /// 设计时嵌入资源url地址
        /// </summary>
        /// <param name="site"></param>
        /// <param name="resourceName"></param>
        /// <returns></returns>
        public static string GetWebResourceUrl(ISite site, string resourceName)
        {
            string resourceUrl = String.Empty;

            if (site != null)
            {
                IResourceUrlGenerator service = (IResourceUrlGenerator)site.GetService(typeof(IResourceUrlGenerator));
                if (service != null)
                {
                    resourceUrl = service.GetResourceUrl(site.Component.GetType(), resourceName);
                }
            }

            // 告诉HttpCompress,不要设置ETag,同时设置Expires为一年后的今天
            resourceUrl += "&expires=1";

            return(resourceUrl);
        }