Adding Keyword And Description meta tags to each page by inheritence
如何加Keyword 和 Description meta tags 到每个页面,看代码:
//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相关推荐
- Setting Meta Tags
Setting Meta Tags 方便搜索引擎搜索: protected void Page_Load(object sender, EventArgs e) { Page.MetaKeywo ...
- SAP Spartacus Customizing Meta Tags
用于元标记的内容尽可能由后端(运行时)数据驱动.例如,产品详细信息页面的图像标签使用主产品图像.另一个示例是产品详细信息页面的标题,它由产品标题.(第一)类别和品牌构成. 如果要进一步自定义元标记的创 ...
- php get meta tags,php怎么抓取网站中meta函数get_meta_tags()
get_meta_tags -- 从一个文件中提取所有的 meta 标签 content 属性,返回一个数组 描述 array get_meta_tags ( string filename [, i ...
- 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 ...
- 如何实现网上试穿_在试穿上出售软件
如何实现网上试穿 There are many talented people out there who have the ability to write scripts, but have li ...
- nuxt 目录结构及配置文件详解
nuxt 目录结构详解 首先我们来看下使用 create-nuxt-app脚手架工具所创建的nuxt项目目录的结构, windows cmd 命令行输入,tree /f /a ,打印如下项目目录结构: ...
- 单页应用的优缺点_单页和多页应用程序之间的优缺点
单页应用的优缺点 Currently, there are two ways of building websites: as multi-page applications (MPAs) or as ...
- NUXT: 视图和模板
视图 本章节的内容阐述了如何在 Nuxt.js 应用中为指定的路由配置数据和视图,包括应用模板.页面.布局和HTML头部等内容. 模板 你可以定制化 Nuxt.js 默认的应用模板. 定制化默认的 h ...
- Foundation Web Design with Dreamweaver 8
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版.作者信息和本声明.否则将追究法律责任. http://blog.csdn.net/topmvp - topmvp Dreamwe ...
最新文章
- ROSE 好的参考资料 http://topic.csdn.net/t/20020716/14/878323.html
- pyinstaller 'utf-8' codec can't decode byte 0xce in position 123: invalid continuation byte
- 078_html5Canvas
- qstring转qchar_Qt 对QString操作
- python property方法_Python——property(使一个方法看起来就像类属性一样)
- 实践 Neutron 前的两个准备工作 - 每天5分钟玩转 OpenStack(78)
- python数据分析师书籍_如何自学成为数据分析师
- security面试_面试必问41道 SpringBoot 面试题,不看亏大了!
- 中文编程对中文编程是否是一枚银弹
- JavaScript特效——开关灯泡
- CCS编译错误:error #10099-D和error#10234-D unresolved symbols remain解决方法
- 优先级Priority
- 基于Linux的socket网络编程项目——游侠手机商城
- 【程序员进阶之路】吴恩达Deeplearning.ai课程学习全体验:深度学习必备课程
- 单周期CPU设计(Verilog)
- pdf分割合并工具下载和使用
- Ubuntu18.04安装Pycharm并将其添加至左侧收藏夹
- React学习中的一个小实战(智能社)
- 织梦进入mysql_织梦phpmyadmin怎么进入
- 用技巧] Http请求偶尔超时+总结各种超时死掉的可能和相应的解决办法