网页的<title> 部分与后台数据库绑定

来源:互联网 发布:青木原树海 知乎 编辑:程序博客网 时间:2024/06/07 00:19

前台页面:

<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title><%=newtitle%></title>


后台页面:

 

   
//定义字段
 public string newtitle;      protected void Page_Load(object sender, EventArgs e)    {              SqlConnection con = new SqlConnection();        string sql2 = "select TOP 20* from  table order by newdate DESC";        SqlDataAdapter da2 = new SqlDataAdapter(sql2, con);        DataSet ds2 = new DataSet();        da2.Fill(ds2, "webinfo2");        DataList2.DataSource = ds2;        DataList2.DataKeyField = "id";        DataBind();        newtitle = "动态title";    }