如何加Keyword 和 Description meta tags 到每个页面,看代码:

Code
//Change the line 
// public partial class SomePage : System.Web.UI.Page
//to
// public partial class SomePage : PageEx
  
public partial class SomePage : PageEx
{
protected void Page_Load(object sender, EventArgs e)
{
Title = "Free Piston Power Pack (FP3)";
this.Description = "Your Description of the page";
this.Keywords = new string[] { "keyword1", "keyword1" ,"keyword1"};
}
}
  
//add the PageEx.cs in the App_Code Directory 
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for PageExPage
/// </summary>
public class PageEx : System.Web.UI.Page
{
private HtmlMeta metaDescription = new HtmlMeta();
private HtmlMeta metaKeywords = new HtmlMeta();
public string Description
{
get { return metaDescription.Content; }
set { metaDescription.Content = value; }
}
  
public string[] Keywords
{
get
{
if (metaKeywords.Content == null)
{
return new string[] { "" };
}
else
{
return metaKeywords.Content.Split(new char[] { ',' });
}
}
set
{
if (value != null)
{
metaKeywords.Content = string.Join(",", value); 
}
}
}
  
public PageEx()
{
Init += new EventHandler(PageEx_Init);
}
void PageEx_Init(object sender, EventArgs e)
{
//Add the description Meta control 
metaDescription.Name = "description";
Page.Header.Controls.Add(metaDescription);
//Add the keywords Meta control 
metaKeywords.Name = "keywords";
Page.Header.Controls.Add(metaKeywords);
}
  
}

文章出处:http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx 【直接拉到最后】

Adding Keyword And Description meta tags to each page by inheritence相关推荐

  1. Setting Meta Tags

    Setting Meta Tags 方便搜索引擎搜索: protected void Page_Load(object sender, EventArgs e) {    Page.MetaKeywo ...

  2. SAP Spartacus Customizing Meta Tags

    用于元标记的内容尽可能由后端(运行时)数据驱动.例如,产品详细信息页面的图像标签使用主产品图像.另一个示例是产品详细信息页面的标题,它由产品标题.(第一)类别和品牌构成. 如果要进一步自定义元标记的创 ...

  3. php get meta tags,php怎么抓取网站中meta函数get_meta_tags()

    get_meta_tags -- 从一个文件中提取所有的 meta 标签 content 属性,返回一个数组 描述 array get_meta_tags ( string filename [, i ...

  4. 5 meta tags for making your website into a iOS Web App

    1. Click on the launch arrow in Safari 2. From the drop down menu select "Add to Home Screen&qu ...

  5. 如何实现网上试穿_在试穿上出售软件

    如何实现网上试穿 There are many talented people out there who have the ability to write scripts, but have li ...

  6. nuxt 目录结构及配置文件详解

    nuxt 目录结构详解 首先我们来看下使用 create-nuxt-app脚手架工具所创建的nuxt项目目录的结构, windows cmd 命令行输入,tree /f /a ,打印如下项目目录结构: ...

  7. 单页应用的优缺点_单页和多页应用程序之间的优缺点

    单页应用的优缺点 Currently, there are two ways of building websites: as multi-page applications (MPAs) or as ...

  8. NUXT: 视图和模板

    视图 本章节的内容阐述了如何在 Nuxt.js 应用中为指定的路由配置数据和视图,包括应用模板.页面.布局和HTML头部等内容. 模板 你可以定制化 Nuxt.js 默认的应用模板. 定制化默认的 h ...

  9. Foundation Web Design with Dreamweaver 8

    版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版.作者信息和本声明.否则将追究法律责任. http://blog.csdn.net/topmvp - topmvp Dreamwe ...

最新文章

  1. ROSE 好的参考资料 http://topic.csdn.net/t/20020716/14/878323.html
  2. pyinstaller 'utf-8' codec can't decode byte 0xce in position 123: invalid continuation byte
  3. 078_html5Canvas
  4. qstring转qchar_Qt 对QString操作
  5. python property方法_Python——property(使一个方法看起来就像类属性一样)
  6. 实践 Neutron 前的两个准备工作 - 每天5分钟玩转 OpenStack(78)
  7. python数据分析师书籍_如何自学成为数据分析师
  8. security面试_面试必问41道 SpringBoot 面试题,不看亏大了!
  9. 中文编程对中文编程是否是一枚银弹
  10. JavaScript特效——开关灯泡
  11. CCS编译错误:error #10099-D和error#10234-D unresolved symbols remain解决方法
  12. 优先级Priority
  13. 基于Linux的socket网络编程项目——游侠手机商城
  14. 【程序员进阶之路】吴恩达Deeplearning.ai课程学习全体验:深度学习必备课程
  15. 单周期CPU设计(Verilog)
  16. pdf分割合并工具下载和使用
  17. Ubuntu18.04安装Pycharm并将其添加至左侧收藏夹
  18. React学习中的一个小实战(智能社)
  19. 织梦进入mysql_织梦phpmyadmin怎么进入
  20. 用技巧] Http请求偶尔超时+总结各种超时死掉的可能和相应的解决办法

热门文章

  1. 程式CSCMSV4黑色炫酷DJ音乐门户模板 音乐网源码
  2. linux: 批量修改文件夹及文件夹下文件的名字
  3. 各平台安装Node.js
  4. 斗地主AI算法——第十六章の样例分析
  5. 华为机试——句子逆序
  6. HTML——初识html,元素 属性 段落 文本格式化 链接 头部入门
  7. Jmock-使用ClassImposteriser扩展mock class对象
  8. 【笔试面试题】腾讯2013实习生面试算法题及参考答案
  9. 二叉树建立及中序遍历C++语言实现
  10. myeclipse 10.7安装过程与初次启动