Asp.Net Dinamik Meta Tag Ekleme (Veri Tabanından Veri çekerek

Asp.Net Dinamik Meta Tag Ekleme (Veri Tabanından Veri çekerek

15. May 2009

Read this article in your language IT | EN | DE | ES

Asp.Net Dinamik Meta Tag Ekleme (Veri Tabanından Veri çekerek.)                                  

Merhaba Arkadaşlar bu makkalede sizlere Canlı Meta Tagların Nasıl oluşturulduğunu Veri tabanından nasıl çekildiğini göstereceğim. bunun için VeriTabanı oluşturmalıyız. Ve 3 tane alan belirlemeliyiz. Bunlar Keywords,PageTitle,Description ve Tablomuzun ismi MetaTag olsun.
şimdi gerisini Aşağıdaki kodları izleyerek yapabilirsiniz...

MasterPage.Cs içinde Sayfanın Page Load' ına Yazılacak Kod
 

protected void Page_Load(object sender, EventArgs e)

{

//Meta ve Keywordslar

      //Önce Dataları Veritabanından Okuyalım

        string PageTitle = "";

        string Keywords = "";

        string Description = "";

 

        SqlConnection sqlCon = new         SqlConnection(ConfigurationManager.ConnectionStrings["MetaTag"].ToString());

        sqlCon.Open();

        SqlCommand sqlCom = new SqlCommand("SELECT Keywords, PageTitle, Description FROM MetaTag",sqlCon);

        SqlDataReader sqlDr = sqlCom.ExecuteReader();

        if (sqlDr.Read())

        {

            Keywords = sqlDr["Keywords"].ToString();

            PageTitle = sqlDr["PageTitle"].ToString();

            Description = sqlDr["Description"].ToString();

        }

        sqlCon.Close();

        Page.Header.Title = PageTitle;

        //  Metadata tagını tanımlamak

        HtmlMeta metaDescription = new HtmlMeta();

        metaDescription.Name = "Robot";

        metaDescription.Content = "index,follow";

        // Sayfaya ekliyoruz.

        Page.Header.Controls.Add(metaDescription);

        // İkinci bir metadata tagını eklemek

        HtmlMeta metaKeywords = new HtmlMeta();

        metaKeywords.Name = "googlebot";

        metaKeywords.Content = "index,follow";

        Page.Header.Controls.Add(metaKeywords);

}

Evet bir makkelenin sonuna daha gelmiş olduk işallah bu makkalede sizlere yararlı bir bilgi olmuştur yeni bir makkalede buluşmak üzere

Saygılarımla Orhan Türk

Kaynak : Web

FacebookDigg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

ASP NET ,

Comments

7/25/2009 8:11:51 AM #
I am quite interesting in this topic hope you will elaborate more on it in future posts.
8/1/2009 3:10:27 AM #
The Subject, or do I appreciate the comments
8/14/2009 9:05:49 PM #
I would like to add your blog to my blogroll please tell me what anchor should I use?
8/14/2009 9:06:24 PM #
I like how you write.Are you interesting in a part time writer job?
8/16/2009 7:25:08 PM #
I like your blog curently we are looking for a part time article writer would you be interested?
8/16/2009 7:25:47 PM #
I would like to add your blog to my blogroll please tell me what anchor should I use?
8/27/2009 6:03:25 AM #
Tried to autotranslate you site not understand the writing any hope deutsch version?
8/27/2009 6:03:58 AM #
I think you have to improve a bit the design and usability of your blog.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Sayfa 0.03125 saniyede yuklendi.