[RESOLVED] Dynamically change the page's shortcut/bookmark icon
I have a webpage that I'd like to display a different shortcut icon depending on whatever the status is of the app. I have the page pin'd in Firefox so I can always see the icon. Any idea how to accomplish this?
*Edit: Answer Post
Re: Dynamically change the page's shortcut/bookmark icon
Hello,
Is this:
http://www.hanselman.com/blog/Enabli...kbarInIE9.aspx
What you are referring to?
I know this is possible with IE9, but I don't know whether this is possible with FireFox. I would suspect that it is know.
Gary
Re: Dynamically change the page's shortcut/bookmark icon
It's literally the shortcut icon I'm trying to change. Basically, make a query and depending on the results, show a different icon.
Code:
<link rel="shortcut icon" href="~/App_Resources/Web_Icon.ico" />
Re: Dynamically change the page's shortcut/bookmark icon
Hello,
What sort of "query" are you wanting to do?
Are you wanting to do this when the page first loads and is rendered to the client, or are you looking to do this on the page once it is loaded using jQuery/AJAX?
Gary
Re: Dynamically change the page's shortcut/bookmark icon
As the page first loads. I have a gridview...if it has any rows I want it to show one icon. If it has no rows, show a different icon.
Re: Dynamically change the page's shortcut/bookmark icon
Hello,
In which case, one technique would be to do the following:
Code:
<link rel="Shortcut Icon" href="~/App_Resources/Web_Icon.ico" runat="server" id="link" />
First of all, add the runat="server" attribute to the link element and give it an id. This means that you will be able to access this element from your code behind.
Then, in your code, you can do something like the following (Note this is C# code):
Code:
link.Attributes["href"] = "~/App_Resources/Web_Icon2.ico";
Hope that helps!
Gary
Re: Dynamically change the page's shortcut/bookmark icon
Ahh, very cool, that did the trick! :) Thanks!
Re: Dynamically change the page's shortcut/bookmark icon
Quote:
Originally Posted by
jsun9
Ahh, very cool, that did the trick! :) Thanks!
Not a problem at all, happy to help!
Gary