Results 1 to 8 of 8

Thread: [RESOLVED] Dynamically change the page's shortcut/bookmark icon

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Resolved [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
    Last edited by jsun9; Aug 8th, 2011 at 12:00 PM.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    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" />

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    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.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Re: Dynamically change the page's shortcut/bookmark icon

    Ahh, very cool, that did the trick! Thanks!

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamically change the page's shortcut/bookmark icon

    Quote Originally Posted by jsun9 View Post
    Ahh, very cool, that did the trick! Thanks!
    Not a problem at all, happy to help!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width