ResolveUrl() public method

public ResolveUrl ( string relativeUrl ) : string
relativeUrl string
return string
 /// <summary>
 /// Simplified Helper function that is used to add script files to the page
 /// This version adds scripts to the top of the page in the 'normal' position
 /// immediately following the form tag.
 /// </summary>
 /// <param name="script"></param>
 public static void IncludeScriptFile(Control control, string scriptFile)
 {
     scriptFile = control.ResolveUrl(scriptFile);
     ClientScriptProxy.ClientScriptProxy.Current.RegisterClientScriptInclude(control, typeof(ControlResources),
                                   Path.GetFileName(scriptFile).ToLower(),
                                   scriptFile);
 }
        public static void ShowMessageBox(Control p, string Message, string BoxTitle, MessageBoxType type)
        {
            Message = Message.Replace("\r\n", "");
            Message = Message.Replace("<BR>", "{BR}");
            Message = Message.Replace("<", "{START}");
            Message = Message.Replace(">", "{END}");
            Message = Message.Replace("\"", "{Q}");


            string ImagePath = string.Format(p.ResolveUrl("~/App_Themes/MessageBox/{0}.png"), type.GetEnumName());

            string script = string.Format(@"<script type=""text/javascript"">
                                 ShowJQMessageBox(' <fieldset style=""direction:rtl;width:400px;max-width:600px;min-width: 300px;"" align=""center""><legend><img  align=""middle"" src=""{0}"" Width=""32"" />{1} </legend>  <span style=""direction:rtl;text-align:right"">{2}</span></fieldset>');
                               </script>", ImagePath, BoxTitle, HttpContext.Current.Server.HtmlEncode(Message));



            script = script.Replace("{BR}", "<BR>");
            script = script.Replace("{START}", "<");
            script = script.Replace("{END}", ">");
            script = script.Replace("{Q}", "\"");

            ScriptManager.RegisterClientScriptBlock(p, p.GetType(), "message", script, false);

        }
        protected override void Process(System.Web.HttpContext context)
        {
            Boolean skipRedirect = false;
            String filename = null;
            String campaignQuerystring = "";

            String encryptedDownload = context.Request.QueryString["d"];
            if (encryptedDownload == null)
            {
                String campaignString = context.Request.QueryString["qs"];
                filename = context.Request.QueryString["filename"];

                //Convert the campaign string to the actual qs that will be appended to the redirect
                campaignQuerystring = CampaignManager.Instance.ConvertTrackingLink(campaignString);
            }
            else
            {
                try
                {
                    filename = ContentManager.DecryptFilename(encryptedDownload);
                    skipRedirect = true;
                }
                catch (Exception)
                {
                    ReturnMissingFileError(context);
                }
            }

            //Get the cms content type for this file
            CmsContent content = ContentManager.Instance.GetFile(filename);
            if (content != null)
            {
                if (!content.RequiresRegistration)
                    skipRedirect = true;
            }
            else
                ReturnMissingFileError(context);

            if (!skipRedirect)
            {
                Control  resolver = new Control();
                String redirect = "~" + content.RegistrationPage + "?" + campaignQuerystring + "&fget=" + AntiXss.UrlEncode(filename);
                redirect = resolver.ResolveUrl(redirect);

                context.Response.Redirect(redirect, true);
            }
            else
            {
                DownloadFile(context, content, filename);
            }
        }
    public static object GetEvalData(string expression)
    {
        string result = String.Empty;

        // Get the Web application configuration.
        Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");

        // Get the 'pages' section.
        PagesSection pagesSection = (PagesSection)configuration.GetSection("system.web/pages");

        bool hasArgs = System.Text.RegularExpressions.Regex.IsMatch(expression, ".+\\(.+\\)", RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.IgnoreCase);

        //Determine the expression result
        if (expression.ToLowerInvariant().StartsWith(STYLESHEET_THEME))
        {
            if (hasArgs)
            {
                expression = expression.Substring(STYLESHEET_THEME.Length + 1, expression.Length - STYLESHEET_THEME.Length - 2);
                System.Web.UI.Control helper = new Control();
                result = helper.ResolveUrl(String.Format(expression, pagesSection.StyleSheetTheme));
            }
            else
            {
                result = pagesSection.StyleSheetTheme;
            }
        }
        else if (expression.ToLowerInvariant().StartsWith(THEME))
        {
            if (hasArgs)
            {
                expression = expression.Substring(THEME.Length + 1, expression.Length - THEME.Length - 2);
                System.Web.UI.Control helper = new Control();
                result = helper.ResolveUrl(String.Format(expression, pagesSection.Theme));
            }
            else
            {
                result = pagesSection.Theme;
            }
        }

        return result;
    }
Example #5
0
        public static string GetContentPageMenu(Control page, string path)
        {
            if(page != null)
            {
                string menu = string.Empty;
                string relativePath = Conversion.GetRelativePath(path);
                Collection<Menu> rootMenus = Core.Menu.GetRootMenuCollection(relativePath);

                if (rootMenus == null)
                {
                    return string.Empty;
                }

                if(rootMenus.Count > 0)
                {
                    foreach(Menu rootMenu in rootMenus)
                    {

                        menu += string.Format(Thread.CurrentThread.CurrentCulture, "<div class='panel panel-default'><div class='panel-heading'><h3 class='panel-title'>{0}</h3></div>", rootMenu.MenuText);

                        Collection<Menu> childMenus = Core.Menu.GetMenuCollection(rootMenu.MenuId, 2);

                        if(childMenus.Count > 0)
                        {
                            foreach (Menu childMenu in childMenus)
                            {
                                menu += string.Format(Thread.CurrentThread.CurrentCulture, "<a href='{0}' title='{1}' data-menucode='{2}' class='list-group-item'>{1}</a>", page.ResolveUrl(childMenu.Url), childMenu.MenuText, childMenu.MenuCode);
                            }
                        }

                        menu += "</div>";

                    }
                }

                return menu;
            }

            return null;
        }
Example #6
0
        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues"></param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
        {
            if ( !string.IsNullOrWhiteSpace( value ) )
            {
                var imagePath = Path.Combine( parentControl.ResolveUrl( "~" ), "GetImage.ashx" );

                // create querystring parms
                string queryParms = string.Empty;
                if ( condensed )
                {
                    queryParms = "&width=100"; // for grids hardcode to 100px wide
                }
                else
                {
                    // determine image size parameters
                    // width
                    if ( configurationValues != null &&
                        configurationValues.ContainsKey( "width" ) &&
                        !String.IsNullOrWhiteSpace( configurationValues["width"].Value ) )
                    {
                        queryParms = "&width=" + configurationValues["width"].Value;
                    }

                    // height
                    if ( configurationValues != null &&
                        configurationValues.ContainsKey( "height" ) &&
                        !String.IsNullOrWhiteSpace( configurationValues["height"].Value ) )
                    {
                        queryParms += "&height=" + configurationValues["height"].Value;
                    }
                }

                string imageUrlFormat = "<img src='" + imagePath + "?id={0}{1}' />";
                return string.Format( imageUrlFormat, value, queryParms );
            }
            else
            {
                return string.Empty;
            }
        }
        public override Control AddTo(Control container)
        {
            var child = new FieldSet
                            {
                                ID = Name,
                                Legend = GetLocalizedText("Legend") ?? Legend,
                                CssClass = CssClass
                            };
            if (string.IsNullOrEmpty(ImageUrl) == false)
            {
                var imageUrl = container.ResolveUrl(ImageUrl);

                var imageStyle = "";
                if (string.IsNullOrEmpty(ImageStyle) == false)
                {
                    imageStyle = string.Format(" style=\"{0}\"", ImageStyle.Replace('"', '\''));
                }

                child.Legend = string.Format("<img src=\"{0}\" alt=\"{1}\"{2} />&nbsp;{1}", imageUrl, child.Legend, imageStyle);
            }

            container.Controls.Add(child);
            return child;
        }
Example #8
0
        /// <summary>
        /// Registers a CSS stylesheet in the page header and if that's not accessible inside of the form tag.
        /// </summary>
        /// <param name="control"></param>
        /// <param name="type"></param>
        /// <param name="key"></param>
        /// <param name="url"></param>
        public void RegisterCssLink(Control control, Type type, string key, string url) {
            if (string.IsNullOrEmpty(url))
                return;

            string lowerUrl = url.ToLower();
            if (cssLinks.Contains(lowerUrl))
                return;  // already added

            Control container = GetHeader(control);

            string output = "<link href=\"" + control.ResolveUrl(url) + "\" rel=\"stylesheet\" type=\"text/css\" >\r\n";
            container.Controls.Add(new LiteralControl(output));

            cssLinks.Add(lowerUrl);
        }
Example #9
0
		public static void ResolveUrl_Load (Page p)
		{
#if TARGET_JVM
			string appPath = "/MainsoftWebApp20";
#else
			string appPath = "/NunitWeb";
#endif
			Control ctrl = new Control ();
			p.Controls.Add (ctrl);
			Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~/MyPage.aspx"), "ResolveClientUrl Failed");

			Assert.AreEqual ("", ctrl.ResolveUrl (""), "empty string");

			Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~"), "~");
			Assert.AreEqual (appPath + "/", ctrl.ResolveUrl ("~/"), "~/");

			Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~/../MyPage.aspx"), "~/../MyPage.aspx");
			Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("~\\..\\MyPage.aspx"), "~\\..\\MyPage.aspx");
			Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("~////MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/folder/MyPage.aspx", ctrl.ResolveUrl ("/folder/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("/NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("\\NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("\\NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("///NunitWeb\\..\\MyPage.aspx", ctrl.ResolveUrl ("///NunitWeb\\..\\MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual (appPath + "/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/../MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual (appPath + "/NunitWeb/MyPage.aspx", ctrl.ResolveUrl ("NunitWeb/./MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("http://google.com/", ctrl.ResolveUrl ("http://google.com/"), "ResolveClientUrl Failed");

			Assert.AreEqual (appPath + "/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");
			Assert.AreEqual ("/MyPage.aspx?param=val&yes=no", ctrl.ResolveUrl ("~/../MyPage.aspx?param=val&yes=no"), "~/../MyPage.aspx");

			Assert.AreEqual (appPath + "/MyPage.aspx", ctrl.ResolveUrl ("./MyPage.aspx"), "ResolveClientUrl Failed");
			Assert.AreEqual ("/MyPage.aspx", ctrl.ResolveUrl ("../MyPage.aspx"), "ResolveClientUrl Failed");

			Assert.AreEqual ("/", ctrl.ResolveUrl (".."), "..");
			Assert.AreEqual ("/", ctrl.ResolveUrl ("../"), "../");
		}
Example #10
0
		/// <summary>
		/// User controls can live in their own folder. 
		/// They can contain Image and Hyperlink controls that have image paths
		/// that are relative to the location of the user control itself.
		/// 
		/// In order to get the last update time of these images, you need to
		/// get their absolute image paths, which take account of both the image path
		/// and the user control path. You can do this by letting the Image or Hyperlink
		/// control resolve the image path.
		/// 
		/// After you've found the resolved path, you can pass that to CombinedFile.LastUpdateTime
		/// to safely get the last update time.
		/// </summary>
		/// <param name="path">
		/// Image path as exposed by the image control.
		/// </param>
		/// <param name="resolver">
		/// The control that will be used to resolve the image path. This would be the 
		/// Image or Hyperlink control itself.
		/// </param>
		/// <returns></returns>
		private string LastUpdateTimeImageControl (string path, Control resolver, bool throwExceptionOnMissingFile)
		{
			string resolvedImageUrl = resolver.ResolveUrl (path);
			return CombinedFile.LastUpdateTime (resolvedImageUrl, throwExceptionOnMissingFile);
		}
Example #11
0
        internal override void Render(HtmlTextWriter writer, Control parent)
        {
            if (!Enabled)
                return;

            if (!BoxStyle.IsEmpty)
                BoxStyle.AddAttributesToRender(writer);
            writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            writer.AddAttribute(HtmlTextWriterAttribute.Id, parent.ClientID + "_ax");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (!string.IsNullOrEmpty(PreTitle))
            {
                if (!PreTitleStyle.IsEmpty)
                    PreTitleStyle.AddAttributesToRender(writer);
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(PreTitle);
                writer.RenderEndTag();
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Id, parent.ClientID + "_axgfx");
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, "Busy Graphic");
            if (!string.IsNullOrEmpty(GfxPath))
                writer.AddAttribute(HtmlTextWriterAttribute.Src, parent.ResolveUrl(GfxPath));
            else
                writer.AddAttribute(HtmlTextWriterAttribute.Src, parent.Page.ClientScript.GetWebResourceUrl(parent.GetType(), "ESWCtrls.ResEmbed.Gfxs.busybox.busy.gif"));
            if (!GfxStyle.IsEmpty)
                GfxStyle.AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();

            if (!string.IsNullOrEmpty(PostTitle))
            {
                if (!PostTitleStyle.IsEmpty)
                    PostTitleStyle.AddAttributesToRender(writer);
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(PostTitle);
                writer.RenderEndTag();
            }

            writer.RenderEndTag();

            if (CoverElements)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(CoverColor));
                writer.AddStyleAttribute("opacity", CoverTransparency.ToString("###.0"));
                writer.AddStyleAttribute("filter", "alpha(opacity=" + (CoverTransparency * 100).ToString("###") + ")");
                writer.AddAttribute(HtmlTextWriterAttribute.Id, parent.ClientID + "_ax_cover");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.RenderEndTag();
            }
        }
Example #12
0
        //Use selected skin's webcontrol skin if one exists
        //or use _default skin's webcontrol skin if one exists
        //or use embedded skin
        public static void ApplySkin(Control telerikControl, string fallBackEmbeddedSkinName, string controlName, string webControlSkinSubFolderName)
        {
            PropertyInfo skinProperty = null;
            PropertyInfo enableEmbeddedSkinsProperty = null;
            bool skinApplied = false;

            try
            {
                skinProperty = telerikControl.GetType().GetProperty("Skin");
                enableEmbeddedSkinsProperty = telerikControl.GetType().GetProperty("EnableEmbeddedSkins");

                if ((string.IsNullOrEmpty(controlName)))
                {
                    controlName = telerikControl.GetType().BaseType.Name;
                    if ((controlName.StartsWith("Rad") || controlName.StartsWith("Dnn")))
                    {
                        controlName = controlName.Substring(3);
                    }
                }


                string skinVirtualFolder = "";
                if (PortalSettings.Current != null)
                    skinVirtualFolder = PortalSettings.Current.ActiveTab.SkinPath.Replace('\\', '/').Replace("//", "/");
                else
                    skinVirtualFolder = telerikControl.ResolveUrl("~/Portals/_default/skins/_default/Aphelia"); // developer skin Aphelia

                string skinName = "";
                string webControlSkinName = "";
                if (skinProperty != null)
                {
                    var v = skinProperty.GetValue(telerikControl, null);
                    if (v != null) 
                        webControlSkinName = v.ToString();

                }
                if (string.IsNullOrEmpty(webControlSkinName)) webControlSkinName = "default";

                if ((skinVirtualFolder.EndsWith("/")))
                {
                    skinVirtualFolder = skinVirtualFolder.Substring(0, skinVirtualFolder.Length - 1);
                }
                int lastIndex = skinVirtualFolder.LastIndexOf("/");
                if ((lastIndex > -1 && skinVirtualFolder.Length > lastIndex))
                {
                    skinName = skinVirtualFolder.Substring(skinVirtualFolder.LastIndexOf("/") + 1);
                }

                string systemWebControlSkin = string.Empty;
                if ((!string.IsNullOrEmpty(skinName) && !string.IsNullOrEmpty(skinVirtualFolder)))
                {
					systemWebControlSkin = HttpContext.Current.Server.MapPath(skinVirtualFolder);
                    systemWebControlSkin = Path.Combine(systemWebControlSkin, "WebControlSkin");
                    systemWebControlSkin = Path.Combine(systemWebControlSkin, skinName);
                    systemWebControlSkin = Path.Combine(systemWebControlSkin, webControlSkinSubFolderName);
                    systemWebControlSkin = Path.Combine(systemWebControlSkin, string.Format("{0}.{1}.css", controlName, webControlSkinName));

                    //Check if the selected skin has the webcontrol skin
                    if ((!File.Exists(systemWebControlSkin)))
                    {
                        systemWebControlSkin = "";
                    }

                    //No skin, try default folder
                    if ((string.IsNullOrEmpty(systemWebControlSkin)))
                    {
                        skinVirtualFolder = telerikControl.ResolveUrl("~/Portals/_default/Skins/_default");
                        skinName = "Default";

                        if ((skinVirtualFolder.EndsWith("/")))
                        {
                            skinVirtualFolder = skinVirtualFolder.Substring(0, skinVirtualFolder.Length - 1);
                        }

                        if ((!string.IsNullOrEmpty(skinName) && !string.IsNullOrEmpty(skinVirtualFolder)))
                        {
                            systemWebControlSkin = HttpContext.Current.Server.MapPath(skinVirtualFolder);
                            systemWebControlSkin = Path.Combine(systemWebControlSkin, "WebControlSkin");
                            systemWebControlSkin = Path.Combine(systemWebControlSkin, skinName);
                            systemWebControlSkin = Path.Combine(systemWebControlSkin, webControlSkinSubFolderName);
                            systemWebControlSkin = Path.Combine(systemWebControlSkin, string.Format("{0}.{1}.css", controlName, webControlSkinName));

                            if ((!File.Exists(systemWebControlSkin)))
                            {
                                systemWebControlSkin = "";
                            }
                        }
                    }
                }

                if ((!string.IsNullOrEmpty(systemWebControlSkin)))
                {
                    string filePath = Path.Combine(skinVirtualFolder, "WebControlSkin");
                    filePath = Path.Combine(filePath, skinName);
                    filePath = Path.Combine(filePath, webControlSkinSubFolderName);
                    filePath = Path.Combine(filePath, string.Format("{0}.{1}.css", controlName, webControlSkinName));
                    filePath = filePath.Replace('\\', '/').Replace("//", "/").TrimEnd('/');
                    
                    if (HttpContext.Current != null && HttpContext.Current.Handler is Page)
                    {
                        ClientResourceManager.RegisterStyleSheet(HttpContext.Current.Handler as Page, filePath);
                    }

                    if (((skinProperty != null) && (enableEmbeddedSkinsProperty != null)))
                    {
                        skinApplied = true;
                        skinProperty.SetValue(telerikControl, webControlSkinName, null);
                        enableEmbeddedSkinsProperty.SetValue(telerikControl, false, null);
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }

            if (skinProperty != null && enableEmbeddedSkinsProperty != null && !skinApplied)
            {
                if ((string.IsNullOrEmpty(fallBackEmbeddedSkinName)))
                {
                    fallBackEmbeddedSkinName = "Simple";
                }

                //Set fall back skin Embedded Skin
                skinProperty.SetValue(telerikControl, fallBackEmbeddedSkinName, null);
                enableEmbeddedSkinsProperty.SetValue(telerikControl, true, null);
            }
        }
Example #13
0
 private static void AddMessageWindow(Control ctrl)
 {
     ClientResourceManager.RegisterScript(ctrl.Page, ctrl.ResolveUrl("~/js/dnn.postbackconfirm.js"));
 }
 private string GetServiceUrl(Control containingControl, bool encodeSpaces) {
     string path = Path;
     if (String.IsNullOrEmpty(path)) {
         throw new InvalidOperationException(AtlasWeb.ServiceReference_PathCannotBeEmpty);
     }
     if (encodeSpaces) {
         path = containingControl.ResolveClientUrl(path);
     }
     else {
         path = containingControl.ResolveUrl(path);
     }
     return path;
 }
 /// <summary>
 /// Simplified Helper function that is used to add script files to the page
 /// This version adds scripts to the bottom of the page just before the
 /// Form tag is ended. This ensures that other libraries have loaded
 /// earlier in the page.
 /// 
 /// This may be required for 'manually' adding script code that relies
 /// on other dependencies. For example a jQuery library that depends
 /// on jQuery or wwScriptLIbrary that is implicitly loaded.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="script"></param>
 public static void IncludeScriptFileBottom(Control control, string scriptFile)
 {
     scriptFile = control.ResolveUrl(scriptFile);
     ClientScriptProxy.ClientScriptProxy.Current.RegisterClientScriptBlock(control, typeof(ControlResources),
                     Path.GetFileName(scriptFile).ToLower(),
                     "<script src='" + scriptFile + "' type='text/javascript'></script>",
                     false);
 }
Example #16
0
        public static String ToAbsoluteUrl(String path)
        {
            Control resolver = new Control();

            path = resolver.ResolveUrl(path);
            if (!path.StartsWith("/"))
                path = "/" + path;

            return "http://" + CurrentSite.ProductionDomain + path;
        }
        /// <summary>
        /// High level helper function  that is used to load script resources for various AJAX controls
        /// Loads a script resource based on the following scriptLocation values:
        /// 
        /// * WebResource
        ///   Loads the Web Resource specified out of ControlResources. Specify the resource
        ///   that applied in the resourceName parameter
        ///   
        /// * Url/RelativeUrl
        ///   loads the url with ResolveUrl applied
        ///   
        /// * empty string (no value) 
        ///   No action is taken and nothing is embedded into the page. Use this if you manually
        ///   want to load resources
        /// </summary>
        /// <param name="control">The control instance for which the resource is to be loaded</param>
        /// <param name="scriptLocation">WebResource, a virtual path or a full Url. Empty to not embed any script refs (ie. user loads script herself)</param>
        /// <param name="resourceName">The name of the resource when WebResource is used for scriptLocation null otherwise</param>
        /// <param name="topOfHeader">Determines if scripts are loaded into the header whether they load at the top or bottom</param>
        public void LoadControlScript(Control control, string scriptLocation, string resourceName, ScriptRenderModes renderMode)
        {
            // Specified nothing to do
            if (string.IsNullOrEmpty(scriptLocation))
                return;

            if (scriptLocation == "WebResource")
            {
                RegisterClientScriptResource(control, control.GetType(), resourceName, renderMode);
                return;
            }
            RegisterClientScriptInclude(control, control.GetType(),
                                        control.ResolveUrl(scriptLocation),
                                        renderMode);
        }
Example #18
0
 /// <summary>
 /// Resolves an application relative url (e.g. ~/path) to its physical url
 /// </summary>
 /// <param name="url">The url to resolve</param>
 /// <returns>The physical url</returns>
 public static String ResolveUrl(String url)
 {
     Control resolver = new Control();
     return resolver.ResolveUrl(url);
 }
Example #19
0
    private string MapPhysicalToURL(string strPhysicalPath)
    {
        string strURL = "";
        System.Web.UI.Control objControl = new System.Web.UI.Control();
        string rootURL = RemoveDomainName(objControl.ResolveUrl("~/"));
        objControl = null;
        string rootLocation = Server.MapPath(rootURL);

        Int32 indexLoc = strPhysicalPath.IndexOf(rootLocation);
        if (indexLoc >= 0)
        {
            strURL = strPhysicalPath.Substring(indexLoc + rootLocation.Length);
            strURL = CatPath(rootURL, strURL, false);
            strURL = strURL.Replace('\\', '/');
        }
        else
        {
            // We are probably were given a remote path.
            strURL = strPhysicalPath;
        }

        return strURL;
    }
Example #20
0
		public void Methods_Deny_Unrestricted ()
		{
			Control c = new Control ();

			c.DataBind ();
			Assert.IsNull (c.FindControl ("mono"), "FindControl");

			Assert.IsFalse (c.HasControls (), "HasControls");
			c.RenderControl (writer);
			Assert.IsNotNull (c.ResolveUrl (String.Empty), "ResolveUrl");
			c.SetRenderMethodDelegate (new RenderMethod (SetRenderMethodDelegate));
#if NET_2_0
			c.ApplyStyleSheetSkin (page);
			Assert.IsNotNull (c.ResolveClientUrl (String.Empty), "ResolveClientUrl");
#endif
			c.Dispose ();
		}
Example #21
0
 /// <summary>
 /// Returns the field's current value(s)
 /// </summary>
 /// <param name="parentControl">The parent control.</param>
 /// <param name="value">Information about the value</param>
 /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
 /// <returns></returns>
 public override string FormatValue( Control parentControl, string value, bool condensed )
 {
     return string.Format( "<a href='{0}image.ashx?{1}' target='_blank'>Image</a>",
         parentControl.ResolveUrl( "~" ),
         value );
 }
        /// <summary>
        /// Registers a CSS stylesheet in the page header and if that's not accessible inside of the form tag.
        /// </summary>
        /// <param name="control"></param>
        /// <param name="type"></param>
        /// <param name="key"></param>
        /// <param name="url"></param>
        public void RegisterCssLink(Control control, Type type, string key, string url)
        {
            if (string.IsNullOrEmpty(url))
                return;

            string lowerUrl = url.ToLower();
            if (cssLinks.Contains(lowerUrl))
                return;  // already added

            Control container = control.Page.Header;
            if (container == null)
                container = control.Page.Form;

            if (container == null)
                throw new InvalidOperationException("There's no header or form to add CSS to Register Resource CSS on the page.");

            string output = "<link href=\"" + control.ResolveUrl(url) + "\" rel=\"stylesheet\" type=\"text/css\" >\r\n";
            container.Controls.Add(new LiteralControl(output));

            cssLinks.Add(lowerUrl);
        }
Example #23
0
        private String GenerateCacheCode(Control control)
        {
            StringBuilder buildString = new StringBuilder();

            for (int i = 0; i < mImages.Count; i++)
            {
                if (!buildString.ToString().Contains("'" + control.ResolveUrl(mImages[i].ToString()) + "'"))
                {
                    buildString.Append("\t" + _variableName + "[" + i + "] = new Image();\r\n");
                    buildString.Append("\t" + _variableName + "[" + i + "].src = '" + control.ResolveUrl(mImages[i].ToString()) + "';\r\n");
                }
            }

            return buildString.ToString();
        }