Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 461 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add meta tag to ASP.Net content page

#1
I have several content pages hanging off of one master page. I need to add a refresh meta tag to one of the content pages but I can't see where I can do this.

Any help would be much appreciated.
Reply

#2
You can add a content place holder on the master page in the head section of the html. You can then add stuff to this content section in your specific content page and it will be outputted to the page header.
Reply

#3
Have not tried this with refresh, but in general you can add a meta tag like this:


var keywords = new HtmlMeta { Name = "keywords", Content = "one,two,three" };
Header.Controls.Add(keywords);

<b>update</b>: it is possible this way. Check Rick Strahl

[To see links please register here]

Reply

#4
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "Title of page";
HtmlMeta tag = new HtmlMeta();
tag.Name = "description";
tag.Content = "description of page";
Header.Controls.Add(tag);
HtmlMeta tagKeyword = new HtmlMeta();
tagKeyword.Name = "keywords";
tagKeyword.Content = "keywords of page";
Header.Controls.Add(tagKeyword );
}

([source url](

[To see links please register here]

))
Reply

#5
add below code in designer page

<meta id="metaDescription" runat="server" name="Description" />

Now add below code to your .cs page

Page.MetaKeywords = "keyword1, keyword2, keyword3";
Page.MetaDescription = "Example of new meta tag";
Reply

#6
One way I found to do this (that I didn't see listed here) was to have a Literal and fill it with whatever kinds of meta tags you want. In my case, I needed to use it without a Master page, to have Facebook recognize a thumbnail image, title, and description:


<head runat="server">
<asp:Literal runat="server" ID="litMeta" />
...
</head>


CodeBehind:

var img = "<meta property=\"og:image\" content=\"thumbnail.jpg\" />";
var title = "<meta property=\"og:title\" content=\"Title\" />";
var desc = "<meta property=\"og:description\" content=\"Description\" />";
litMeta.Text = img + title + desc;
Reply

#7
[This page][1] explains the new feature: **ASP.Net 4** adds 2 new Meta tag related properties to the Page. They can be used to set meta tags for keywords and description.

**You can set them in the code behind:**

Page.MetaKeywords = "keyword1, keyword2, keyword3";
Page.MetaDescription = "Example of new meta tag support in ASP.Net 4";

**You can also set in the @Page directive:**

<%@ Page Language="C#" AutoEventWireup="true"
MetaKeywords="keyword1, keyword2, keyword3"
MetaDescription="Example of new meta tag support in ASP.Net 4"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

The ouput of either of these methods renders html similar to the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
ASP.NET 4 Meta Tag Support
</title>
<meta name="description" content="Example of new meta tag support in ASP.Net 4" />
<meta name="keywords" content="keyword1, keyword2, keyword3" />
</head>
<body>
</body>
</html>


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through