Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Window > IconUrl with relative path

Not answered IconUrl with relative path

Feed from this thread
  • James avatar

    Posted on May 25, 2010 (permalink)

    Is it possible to set the IconUrl property in the RadWindowManager with a relative path like: "~/images/myimage.png" 

    It doesn't seem to be working for me - I get a blank space where the image should be.  I'm trying to do this in a master page.  Thanks.

    Reply

  • Posted on May 26, 2010 (permalink)

    Hello James,

    I tried setting the IconUrl and got it working. I am using RadControls version 2010, 1, 309, 35.
    Here is the markup that I used.

    aspx:
     
    <telerik:RadWindowManager IconUrl="../Images/square.png" ID="RadWindowManager1" 
        runat="server" DestroyOnClose="true">  
        <Windows> 
            <telerik:RadWindow ID="W1" NavigateUrl="Window1.aspx" VisibleOnPageLoad="true">  
            </telerik:RadWindow> 
        </Windows> 
    </telerik:RadWindowManager> 

    Could you provide the code that you tried, if this doesnt help?

    Regards,
    Princy.

    Reply

  • Petio Petkov Petio Petkov admin's avatar

    Posted on May 26, 2010 (permalink)

    Hi James,

    I tested the following code with the latest RadWindow for ASP.NET AJAX version (2010.1.519), and it works as expected - the image was shown:
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server" IconUrl="~/Files/for test.jpg">
                <Windows>
                    <telerik:RadWindow ID="RadWindow1" VisibleOnPageLoad="true" NavigateUrl="http://www.google.com"></telerik:RadWindow>
                    <telerik:RadWindow ID="RadWindow2" VisibleOnPageLoad="true" NavigateUrl="http://www.telerik.com"></telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>
        </div>
        </form>
    </body>
    </html>
    There was a problem in the previous versions if the path had spaces (e.g. ~/My Path/My File.jpg) . If you remove the spaces(e.g. ~/MyPath/MyFile.jpg) everything should be fine.

    If your project is web application - RadWindow's IconUrl will  work not correctly when you add your application directly to the server root (e.g. ApplicationPath is "/"), otherwise it will work as expected(e.g. Application Path is  "/ApplicationName/"). We already logged this problem and we will fix it in one of our future releases.

    All the best,
    Petio Petkov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

    Reply

  • James avatar

    Posted on May 26, 2010 (permalink)

    Hmmm it is still not working for me.  Here are more details:

    The window manager is defined in a Master page:
    <telerik:RadWindowManager ID="windowManager" runat="server" AutoSize="True" Modal="True" Skin="Outlook" Behaviors="Close, Move" VisibleStatusbar="False" ShowContentDuringLoad="false" style="z-index: 9500" IconUrl="~/images/ts_globe_20.png">  
    </telerik:RadWindowManager> 
             

    The window is being created via javascript:
    function OpenModalWithUrl(url)  
    {  
        var oManager = GetRadWindowManager();  
        if (oManager) oManager.open(url, null);  

    I'm using version 2010.1.415.35 of Telerik, Visual Studio 2008, IE 8, and experiencing this problem in the debugger. 

    If I replace "~/images/ts_globe_20.png" with "images/ts_globe_20.png" or "../images/ts_globe_20.png" (depending on where the page resides), it works.

    Reply

  • Hulky avatar

    Posted on May 27, 2010 (permalink)

    Check the HTML dump of the page where RadWindow is. At the end of the page, you should see something like this:


    Sys.Application.add_init(function() {
        $create(Telerik.Web.UI.RadWindow, {
    .............

    What is the path to the icon there? I don't think the problem is related to the window control (it is the asp.net framework that is responsible for converting the ~ to the app's root) though... it looks more like a configuration issue to me.



    Reply

  • Petio Petkov Petio Petkov admin's avatar

    Posted on May 27, 2010 (permalink)

    Hello James,

    When you open a RadWindow via the open client-side method it will be created on the client and IconUrl will not be used. The following code is a simple workaround which will change the IconUrl on the client.
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head id="Head1" runat="server">
        <title></title>
         
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
        <script type="text/javascript">
            function OpenModalWithUrl(url)
            {
                var oManager = GetRadWindowManager();
                if (oManager)
                {
                    var oWin = oManager.open(url, null);
                    var iconUrl = oWin.get_iconUrl();
                    // set the new ICon
                    oWin._titleIconElement.style.background = "transparent url('"+iconUrl+"') no-repeat scroll 0px 0px";
                }
            }  
        </script>
         <telerik:RadWindowManager ID="windowManager" runat="server" AutoSize="True" Modal="True" Skin="Outlook" Behaviors="Close, Move"
             VisibleStatusbar="False" ShowContentDuringLoad="false" style="z-index: 9500" IconUrl="~/Files/Gifi.gif">   
            </telerik:RadWindowManager>  
            <button  type="button" value="showIT" onclick="OpenModalWithUrl('http://www.google.com')" ></button>
        </div>
        </form>
    </body>
    </html>
    We will do our best to fix this problem for some of the RadControls for ASP.NET AJAX future releases. Your Telerik points were updated.

    Sincerely yours,
    Petio Petkov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

    Reply

  • James avatar

    Posted on May 27, 2010 (permalink)

    Thanks Petio, that... almost worked for me.

    I noticed that the value of oWin.get_iconUrl() was "//images/ts_globe_20.png".  This was not working.  If I changed the url to either "/images/ts_globe_20.png" or to "//localhost:2331/images/ts_globe_20.png" it works.  I haven't deployed the website yet, all my testing so far has only been in visual studio debugger - I'm not sure if that makes a difference.

    My work around was to update my js method to replace the "//" with "/".
    function OpenModalWithUrl(url)  
    {  
        var oManager = GetRadWindowManager();  
        if (oManager)   
        {  
            var oWin = oManager.open(url, null);  
            var iconUrl = oWin.get_iconUrl();  
            iconUrl = iconUrl.replace("//","/");  
            oWin._titleIconElement.style.background = "transparent url('" + iconUrl + "') no-repeat scroll 0px 0px";  
        }  

    Let me know if there is a better approach.  For now, this appears to work for me but I have yet to deploy it to my web server to test.  Thanks!

    Reply

  • Petio Petkov Petio Petkov admin's avatar

    Posted on Jun 1, 2010 (permalink)

    Hello James,

    At the moment this is the only one solution. We will do our best to resolve all known issues with RadWindow's IconUrl property till the next official release.
    Let us know if you have any other questions.

    Kind regards,
    Petio Petkov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

    Reply

  • fred williams avatar

    Posted on Nov 24, 2010 (permalink)

    Just to chime in here, I had the exact same problem where the icon wouldn't show up during testing. It does however work fine and the icon shows once the application is deployed. I'm not sure if the original poster ever deployed his app but if not he should and then reply here to see if it worked. 

    Reply

  • James avatar

    Posted on Jun 16, 2011 (permalink)

    The fix that was suggested with the javascript worked for awhile.  However, after recently upgrading to a newer version of Telerik, it has stopped working and the icon no longer shows up.  We are currently using version 2011.1.413.35

    Reply

  • Georgi Tunev Georgi Tunev admin's avatar

    Posted on Jun 17, 2011 (permalink)

    Hi James,

    Just to clarify - is your application set as root website? If so, indeed this problem was reported several times during the years and our investigation shows that the problem is not directly related to our control, but to the way the framework works. Basically, our control does not affect the Url in any way - we leave this entirely to the framework's Url resolving logic.
    There seems to be a problem with Request.ApplicationPath in some specific scenarios - check this blog post for more details. As you will see, the problem occurs with the standard controls as well.

    This being said, I would suggest to set the IconUrl property from codebehind, by using the ResolveUrl method:
    radWindow.IconUrl = ResolveUrl ("~/pathToImage/image.png")

    I hope this helps. If it doesn't, or your scenario is different than the one described in the blog post, please provide more details about your exact setup so we can investigate further.

    Greetings,
    Georgi Tunev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

    Reply

  • Posted on Aug 23, 2011 (permalink)

    This one is still not solved in the Q2 version?

    BR,
    Marc

    Reply

  • Marin Bratanov Marin Bratanov admin's avatar

    Posted on Aug 24, 2011 (permalink)

    Hello Marc,

    This seems to be working fine on my end: http://screencast.com/t/gGyqrbxxbI. I tested with the Q2 2011 version and with the latest internal build (2011.2.823 as of 24th of August). Since the Q2 release there have been some more improvements on the iconUrl, but they are in its client-side API.


    Kind regards,
    Marin
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Attached files

    Reply

  • Sérgio avatar

    Posted on Feb 1, 2012 (permalink)

    Thanks very much. This solution works fine with me.

    I think this is a more elegant way to do it (on the aspx side instead of setting it on the codebehind):

    <telerik:radwindowmanager ID="RadWindowManager1" runat="server" IconUrl='<%= ResolveUrl("~/pathToImage/image.png") %>'>


    Edited:
    My "elegant way" works only at certain cases. In other gives me this JScript error:
    this._titleIconElement.style.background="transparent url('"+c+"') no-repeat scroll 0px 0px";

    I moved all to codebehind and works fine.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Window > IconUrl with relative path
Related resources for "IconUrl with relative path"

ASP.NET Window Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]