Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI
how can we add the meta tag to the master page by writting the code in the conten page coding
Posted

Hi

Create a contentplaceholder in master page

XML
<head >
    <asp:ContentPlaceHolder ID="ContentPlaceHolderMetaData" runat="server">
    </asp:ContentPlaceHolder>

</Head>



After that you can add meta tag in this contentplaceholder from child form
Dynamically
 
Share this answer
 
I think you want to set meta tag from code ..
(using below code you can set different meta tag/title for each page-which is required for seo)
Call below function in Page_Load Event...
C#
public void settitle(string s1, string s2, string s3)
   {
       HtmlTitle htmltitle = new HtmlTitle();
       htmltitle.Text = s1;
       Header.Controls.Add(htmltitle);

        //  or title can be set as
        Page.Title = pagetitle;

       HtmlMeta htmlmeta = new HtmlMeta();
       htmlmeta .Name = "keywords";
       htmlmeta .Content = s2;
       Header.Controls.Add(htmlmeta );

       HtmlMeta htmlmeta2 = new HtmlMeta();
       htmlmeta2.Name = "description";
       htmlmeta2.Content = s3;
       Header.Controls.Add(htmlmeta2);
   }


Source : Add Dynamically Meta tage, title tag using c# code[^]

If you find help from it plz upvote and mark as solution this.
Thanks
 
Share this answer
 
v4
Comments
lakshmichawala 23-Jan-13 2:54am    
Hi this should be done in the content page.can u help in this regard
Hemant Singh Rautela 23-Jan-13 2:57am    
yes, in each page where you want to put meta tag.
If you set for masterpage then it will same for all child page which is not good for seo...
for proper seo each page has unique title and different meta tag description/keywords..
lakshmichawala 23-Jan-13 5:25am    
hi hemantrautela ..thanks for ur help
lakshmichawala 23-Jan-13 5:29am    
hi can u plz guide how to set this tag dynamically <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> using the above code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900