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

Calling set_iconUrl Doesn't Change Existing Window's Icon

11 Answers 105 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 24 Mar 2011, 03:27 PM
I have a RadWindow that I show for two differing purposes, and this window is shown when either one of two respective buttons is clicked.  I want to set the window's title and icon based on which button was clicked.  Here's my code:

// Determine which item was clicked
if (eventArgs.get_item().get_text() == "Lock and Submit") {
    // Open the dialog
    var objWindow = $find("<%=rwLockAndSubmitPlan.ClientID%>");
    objWindow.set_title(eventArgs.get_item().get_text());
    objWindow.set_iconUrl("\Images/lock.png");
    objWindow.setUrl("\Dialogs/LockAndSubmitPlan.aspx?mode=lockandsubmit");
    objWindow.show();
}
else if (eventArgs.get_item().get_text() == "Provide Explanations") {
    // Open the dialog
    var objWindow = $find("<%=rwLockAndSubmitPlan.ClientID%>");
    objWindow.set_title(eventArgs.get_item().get_text());
    objWindow.set_iconUrl("\Images/notepad.gif");
    objWindow.setUrl("\Dialogs/LockAndSubmitPlan.aspx?mode=provideexplanations");
    objWindow.show();
}

The issue is that while the window's title is, in fact, changed based on the button that was clicked, the window's icon is not.  The first time I open the dialog, the window's icon is set, but that icon remains the window icon from that point on, not matter which button is clicked.

My RadWindowManager is defined as follows:

<telerik:RadWindowManager runat="server" ID="rwmRadWindowManager" VisibleStatusbar="false" ReloadOnShow="true">
    <Windows>
        <telerik:RadWindow runat="server" ID="rwLockAndSubmitPlan" Modal="true" ReloadOnShow="true" 
            VisibleTitlebar="true" Behaviors="Close" OnClientPageLoad="OnClientPageLoad_SpendingPlan" 
            OnClientClose="OnClientClose_Spending_Plan" Width="550" Height="450" />
    </Windows>
</telerik:RadWindowManager>

And, the OnClientPageLoad_SpendingPlan function is defined as follows:

function OnClientPageLoad_SpendingPlan(objWindow, objArguments) {
    objWindow.set_status("");
}

Perhaps this is a quick fix, so a prompt response would be much appreciated!  Thank you!

11 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Mar 2011, 12:03 PM
Hello Ryan,

Try setting the iconUrl as follows.
Javascript:
objWindow.set_iconUrl("../Images/lock.png");

Thanks,
Shinu.
0
Ryan
Top achievements
Rank 1
answered on 25 Mar 2011, 01:22 PM
Sorry, that didn't do the trick.  "\Images/..." takes the directory to the web app's root, and "../Images/..." only takes it up one level.  I actually am calling the code from a page in the root directory, so I tried just using "Images/...", but still no luck.  Any other thoughts?
0
Svetlina Anati
Telerik team
answered on 29 Mar 2011, 12:07 PM
Hi Ryan,

 Your question is a general question about resolving relative path and you will face teh very same problem if you use standard HTML and no RadControls at all.

What I suggest is to call teh server method ResolveUrl e.g as shown below:

// Determine which item was clicked 
if (eventArgs.get_item().get_text() == "Lock and Submit") { 
    // Open the dialog 
    var objWindow = $find("<%=rwLockAndSubmitPlan.ClientID%>"); 
    objWindow.set_title(eventArgs.get_item().get_text()); 
    objWindow.set_iconUrl("\Images/lock.png"); 
    objWindow.setUrl("\Dialogs/LockAndSubmitPlan.aspx?mode=lockandsubmit"); 
    objWindow.show(); 
else if (eventArgs.get_item().get_text() == "Provide Explanations") { 
    // Open the dialog 
    var objWindow = $find("<%=rwLockAndSubmitPlan.ClientID%>"); 
    objWindow.set_title(eventArgs.get_item().get_text()); 
     var resolvedUrl = '<%= ResolveUrl("~/Images/notepad.gif")%>';
     objWindow.set_iconUrl(resolvedUrl);
    objWindow.setUrl("\Dialogs/LockAndSubmitPlan.aspx?mode=provideexplanations"); 
    objWindow.show(); 
}
All the best,
Svetlina
the Telerik team
0
Ryan
Top achievements
Rank 1
answered on 29 Mar 2011, 01:30 PM
Thanks for your response.  Unfortunately, using ResolveUrl produced the same result as "\Images..." and "../Images..." did.  The only difference that ResolveUrl would have provided was that the full URL path would be supplied as opposed to a relative URL, though they both resolve to the same thing in the end.

Any other thoughts?  Thanks!
0
Svetlina Anati
Telerik team
answered on 01 Apr 2011, 09:09 AM
Hi Ryan,

 Did you try my suggestion? Or probably I did not correctly understand your setup and requirement? The ResolveUrl method should evaluate the root by the fact that the tilde is used this should work as you describe your requirement. Please, test my suggestion and in case the issue persists, provide detailed reproduction instructions and we will do our best to help.

Greetings,
Svetlina
the Telerik team
0
Ryan
Top achievements
Rank 1
answered on 01 Apr 2011, 03:00 PM
Hello -

As noted in my previous post, I did try your solution and it did not work.  Also, I've posted my code to my initial post, so please refer to that for an example.  Please let me know how else I might be able to resolve this problem.
0
Svetlina Anati
Telerik team
answered on 06 Apr 2011, 09:04 AM
Hi Ryan,

 As far as I understand, you say that the icon url path you provide  is correct - am I right? If so, you assume that the problem is that the RadWindow doe snot set the icon. there was such a problem in previous versions but it is fixed now - do you by any chance use an old version of RadControls?

I tested setting dynamically new icon url which a valid one and it works correctly on my side. You can test it with the following code:The code above keeps your logic - how you define and open the RadWindow, only some custom logic you have used which is not related to RadWindow and the urls are different (but you say that yours are valid and thus it does not matter).


<!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">
    <script type="text/javascript">
  
        var flag = true;
        function openRadWindow2() {
            var oWnd = $find("<%=rwLockAndSubmitPlan.ClientID%>");
            var originalUrl = flag ? "http://www.google.com" : "http://codechanger.com"
            oWnd.set_iconUrl(originalUrl + "/favicon.ico");
            oWnd.show();
            flag = !flag;
        }
  
        function OnClientPageLoad_SpendingPlan(objWindow, objArguments) {
            objWindow.set_status("");
        }
    </script>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <asp:Button ID="Button2" runat="server" OnClientClick="openRadWindow2();return false;"
        Text="Open Window of other page" />
    <telerik:RadWindowManager runat="server" ID="rwmRadWindowManager" VisibleStatusbar="false"
        ReloadOnShow="true">
        <Windows>
            <telerik:RadWindow runat="server" ID="rwLockAndSubmitPlan" Modal="true" ReloadOnShow="true"
                VisibleTitlebar="true" Behaviors="Close" OnClientPageLoad="OnClientPageLoad_SpendingPlan"
                Width="550" Height="450" />
        </Windows>
    </telerik:RadWindowManager>
    </form>
</body>
</html>




Please, test the code above with your version and let us know whether it works. In case it does, please, make sure that your urls are correct and also that your custom code (condition met to change the icon, etc) is working as you expect.

Kind regards,
Svetlina
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
Ryan
Top achievements
Rank 1
answered on 06 Apr 2011, 03:43 PM
Thank you for your reply.  I'm afraid you're not understanding my full issue.  Please update your code to have a second <asp:Button> show the dialog with a different iconUrl, and let me know if you can get that to work.
0
Svetlina Anati
Telerik team
answered on 11 Apr 2011, 08:05 AM
Hello Ryan,

 Actually, there is no need to use a second button - the global variable called flag in my code toggles the two different logics. However, in order to follow your instructions I reworked the demo with two buttons as follows:

<%@ Page Language="C#" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="ProfileToolTip.ascx" TagName="ProfileToolTip" TagPrefix="uc2" %>
<!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">
    <script type="text/javascript">
  
  
        function openRadWindow2(iconUrl) {
            var oWnd = $find("<%=rwLockAndSubmitPlan.ClientID%>");
            oWnd.set_iconUrl(iconUrl);
            oWnd.show();
  
        }
  
        function OnClientPageLoad_SpendingPlan(objWindow, objArguments) {
            objWindow.set_status("");
        
    </script>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <asp:Button ID="Button2" runat="server" OnClientClick="openRadWindow2('http://www.google.com/favicon.ico');return false;"
        Text="Open Window of other page 1" />
    <asp:Button ID="Button1" runat="server" OnClientClick="openRadWindow2('http://codechanger.com/favicon.ico');return false;"
        Text="Open Window of other page 2" />
    <telerik:RadWindowManager runat="server" ID="rwmRadWindowManager" VisibleStatusbar="false"
        ReloadOnShow="true">
        <Windows>
            <telerik:RadWindow runat="server" ID="rwLockAndSubmitPlan" Modal="true" ReloadOnShow="true"
                VisibleTitlebar="true" Behaviors="Close" OnClientPageLoad="OnClientPageLoad_SpendingPlan"
                Width="550" Height="450" />
        </Windows>
    </telerik:RadWindowManager>
    </form>
</body>
</html>


As you see, in the code above, the icon is correctly set - once to google icon and the next time - to the icon of the code converter. Please, test the code and let me know how to reproduce the issue.

All the best,
Svetlina
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
Ryan
Top achievements
Rank 1
answered on 11 Apr 2011, 01:28 PM
Thanks for your reply.  I've tested your code in my site, and it does not work as expected.  It performs the same way my existing logic does - whichever button is clicked first sets the icon URL for the window, no matter which button is clicked thereafter.  The RadWindowManager, RadWindow, and javascript are all in the same ASPX page, and are not in any UpdatePanels.  Any other thoughts?

Thanks again.
0
Marin Bratanov
Telerik team
answered on 13 Apr 2011, 08:12 AM

Hi Ryan,

The only possible issue is the positioning of the icon when a large icon is used under some browsers (IE and Chrome), but that is a browser limitation and is not related to the Telerik controls.

Here is a video from my experiment and as you can see it seems to be working fine: http://screencast.com/t/HO9NON8w6up.

If you keep experiencing difficulties please open a support ticket and send us a sample project that displays your issue.



All the best,
Marin
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.

Tags
Window
Asked by
Ryan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ryan
Top achievements
Rank 1
Svetlina Anati
Telerik team
Marin Bratanov
Telerik team
Share this question
or