you can improvize according to your needs. Hope i understood your correctly.
%@ Page Title="" Language="C#"
MasterPageFile="MetaTagMasterPage.master"
AutoEventWireup="true"
CodeFile="MetaTagforContentPages.aspx.cs"
Inherits="General_MetaTagforContentPages" %> <asp:Content ID="Content1"
ContentPlaceHolderID="cpHeadMain" Runat="Server"> <title id="title" runat="server">
Initial Title Here</title>
<meta name="description" content="description"
id="description" runat="server" /> <meta name="keywords" content="keys"
id="keywords" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMain"
Runat="Server"> </asp:Content>
using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Data.Sql; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class General_MetaTagforContentPages : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string query = "select * from MetaInfo";
SqlConnection myconnection = new SqlConnection
(ConfigurationManager.ConnectionStrings ["MenuDbConnectionString"].ConnectionString); SqlCommand SqlCmd = null; SqlCmd = new SqlCommand(query, myconnection); SqlCmd.Connection.Open(); SqlCmd.ExecuteNonQuery(); SqlDataAdapter ad = new SqlDataAdapter(SqlCmd); DataTable dt = new DataTable(); ad.Fill(dt); title.InnerHtml = dt.Rows[0]["PageTitle"].ToString(); description.Attributes.Add("content" ,dt.Rows[0] ["MetaDesc"].ToString()); keywords.Attributes.Add("content" ,dt.Rows[0] ["MetaKeyword"].ToString());
}
}
hope this helps or gives you an ideaThanks |
No comments:
Post a Comment