ASP.NET / C#

Dynamic Keywords via VB.NET

If you want to control the keywords of your pages by keeping that information either in a separate file or a database then you can code your asp.net page to dynamically render the keywords for that page. Note: this also works for dynamically displaying your page’s descriptions.

How to code in C#


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;

public partial class: AuthorizedPage
{
     protected System.Web.UI.HtmlControls HtmlForm Products;
private Content content;
protected Int32 cid = 0;
public string animeNam = "Clear.gif";
protected string strAnimeExtension = "Clear.gif";
private DataTable dt;
protected System.Web.UI.HtmlControls HtmlForm HomePg;

public AuthorizedPage pageerror;
private string tmpdesc; //used to hold temp description
private string tmpkeywords; //used to hold temp keywords
public void Page_Load(object sender, System.EventArgs e)

{

cid = Convert.ToInt32(Request.QueryString["cid"]);
Session.Contents["cid"] = cid;

try
{
content = new Content(appEnv.GetConnection());
dt = content.GetContentForPID(cid);

if (dt.Rows.Count > 0)
   {
lbBody.Text = dt.Rows[0]["Body"].ToString();

//Begin Custom Page Titles Here:
this.Page.Header.Title = dt.Rows[0]["headline"].ToString();

//First put the strings into a variable
tmpdesc = dt.Rows[0][Tagline"].ToString();
tmpkeywords = dt.Rows[0][keywords].ToString();

// Second variables into the meta tags:
this.tagDesc.Attributes.Add("content", this.tmpdesc);
this.tagKeywords.Attributes.Add("content", this.tmpkeywords);
}

else
  {
      this.Page.Header.Title = "Multimedia Designs";
    }
}
catch
{
pageerror.Page_Error("There was an error retrieving the Content.");
}

}

#region
Web Form Designer generated code override protected void
 OnInit(EventArgs e)

{
//CODEGEN: This call is required by the ASP.NET Web Form Designer.

// InitializeComponent();
base.OnInit(e);
}

// Required method for Designer support - do not modify
// the contents of this method with the code editor.

private void InitializeComponent()

{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s