locked
Append or Add Description, Keywords, Title to Master Page RRS feed

  • Question

  • User-909867351 posted

    Hi

    I want to replace /add information Description Title etc to MasterPage. I try the soltuin presentend http://lionfishtechnologies.com/developers/tips/c-sharp_add_meta_keywords_description_to_master_page.html but it seems not work for me. Here is my case:

    MasterPage

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="lixo.master.cs" Inherits="lixo" %>
    <!DOCTYPE html>
    <html>
    <head runat="server">    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
         <meta name="title" content=" Este é o titulo"/>   
        <meta name="description" content="Esta é Master" ⁄>
        <title></title>
        <asp:ContentPlaceHolder id="head" runat="server">       
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">        
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html>
    

    Now here is my page child code

    public partial class lixo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Header.Description += ", Adiciona texto a MasterPage";
           
        }
    }

    The description I get is only 

    Esta é Master

    not the one I expected 

    Esta é Master, Adiciona texto a MasterPage

    any help, please?

    Thank you

    Sunday, March 11, 2018 5:45 PM

Answers

  • User-1838255255 posted

    Hi mariolopes,

    According to your description and code, I make a test in my side, it found it works, please check:

    Sample Code:

    protected void Page_Load(object sender, EventArgs e)
            {
                string value = Header.Description;
                string newvalue = value + ", Adiciona texto a MasterPage";
                Header.Description = newvalue;
            }

    Result:

    Best Regards,

    Eric Du 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 12, 2018 7:05 AM