数据库采用SQL Server 2005 Express Edition, 数据库构造就不说了。
SQL语句: SELECT title, keywords, description FROM PageInfo WHERE (url= @url)SqlDataSource,名字为sds
具体的代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
public partial class Header_cs : System.Web.UI.MasterPage {
protected void Page_Load(object sender, EventArgs e) {
sds.SelectParameters.Add("url",
Request.AppRelativeCurrentExecutionFilePath);
IDataReader reader =
(IDataReader)sds.Select(new DataSourceSelectArguments());
if (reader.Read()) {
Page.Header.Title = reader.GetString(0);
HtmlMeta meta1 = new HtmlMeta();
HtmlMeta meta2 = new HtmlMeta();
meta1.Name = "keywords";
meta1.Content = reader.GetString(1);
meta2.Name = "description";
meta2.Content = reader.GetString(2);
Page.Header.Controls.Add(meta1);
Page.Header.Controls.Add(meta2);
}
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |