1
 <head>
     <title id="Title" runat="server"></title>
     <link id="TitleLogo" runat="server" rel="shortcut icon" href="Images/TM32.ico"/>  
 </head>

Here I added in head tag title with the link where I am adding image. I want to change that at run time.

ItsPete
  • 2,363
  • 3
  • 27
  • 35
pooja
  • 29
  • 4

2 Answers2

0

I assume that you are using Master page, so that you can change Href at runtime by using Master.FindControl:

(Master.FindControl("TitleLogo") as HtmlLink).Href = "Images/TM33.ico";
Selim Yildiz
  • 5,254
  • 6
  • 18
  • 28
0

Once you have added the "runat" and "id" fields you should have access to it in your code behind in any of the life cycle methods as an HtmlGenericControl.

C#

protected HtmlGenericControl TitleLogo;

private void Page_Load(object sender, System.EventArgs e)
{
   if(!Page.IsPostBack)
   {
      TitleLogo.Attributes["href"] = "Images/TM33.ico";
   }
}    

And in VB

    Protected TitleLogo As HtmlGenericControl

    Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not Page.IsPostBack Then
            TitleLogo.Attributes("href") = "Images/TM33.ico"
        End If
    End Sub
Cueball 6118
  • 517
  • 4
  • 16
  • Can you be more specific please. Do you get an error? Are you saying the icon has not changed? Please make sure you look at the HTML source code as you will find the shortcut icon is cached by your browser. – Cueball 6118 Feb 11 '20 at 12:34
  • actually while inspecting the page in the head section image is added in href tag but it not shown in browser. – pooja Feb 11 '20 at 12:56
  • You will find the shortcut icon is agressively cached in most broswers as it rarely changes in normal circumstances. To test try using a different browser or a different computer if you can (or even a different URL if your dev environment allows). – Cueball 6118 Feb 11 '20 at 20:10