Search code examples
c#htmlasp.netfaviconpage-title

How to Add favicon and page title on to a asp.net page


I have aspx page like picture : enter image description here

I want to favicon and page title on this page. I learned this : favicon and page title inside in <head> tag. I tried something but I didn't. I get many error. How can I do (Without disturbing the code) any idea please ?

I added on .cs code:

protected void Page_Load(object sender, EventArgs e)
{
    this.Title = "Title";
} 

//I get this error : Using the Title property of Page requires a header control on the page. (e.g. )


Solution

  • In the case of the code you've shown, you can add any head tags you need to the UxContentHead content section:

    <asp:Content ID="Content1" ContentPlaceHolderID="UxContentHead" runat="server">
          <!-- meta tags ... -->
          <title>My Page Title</title>
          <link rel="icon" 
                type="image/png" 
                href="http://example.com/myicon.png" />
          <link rel="shortcut icon" 
                type="image/png"
                href="http://example.com/myicon.png"/>
    </asp:Content>