This is a migrated thread and some comments may be shown as answers.

IconUrl with relative path

13 Answers 296 Views
Window
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 25 May 2010, 11:17 PM
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.

13 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 May 2010, 02:45 PM
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.
0
Petio Petkov
Telerik team
answered on 26 May 2010, 03:33 PM
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.
0
James
Top achievements
Rank 1
answered on 26 May 2010, 04:47 PM
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.

0
GT
Top achievements
Rank 1
answered on 27 May 2010, 03:59 PM
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.



0
Petio Petkov
Telerik team
answered on 27 May 2010, 04:06 PM
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.
0
James
Top achievements
Rank 1
answered on 27 May 2010, 05:39 PM
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!

0
Petio Petkov
Telerik team
answered on 01 Jun 2010, 03:48 PM
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.
0
fred williams
Top achievements
Rank 1
answered on 24 Nov 2010, 08:02 PM
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. 
0
James
Top achievements
Rank 1
answered on 16 Jun 2011, 11:15 PM
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
0
Georgi Tunev
Telerik team
answered on 17 Jun 2011, 11:59 AM
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.

0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 23 Aug 2011, 11:17 AM
This one is still not solved in the Q2 version?

BR,
Marc
0
Marin Bratanov
Telerik team
answered on 24 Aug 2011, 08:55 AM
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 >>

0
Sérgio
Top achievements
Rank 1
answered on 01 Feb 2012, 08:14 PM
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.
Tags
Window
Asked by
James
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Petio Petkov
Telerik team
James
Top achievements
Rank 1
GT
Top achievements
Rank 1
fred williams
Top achievements
Rank 1
Georgi Tunev
Telerik team
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Marin Bratanov
Telerik team
Sérgio
Top achievements
Rank 1
Share this question
or