• We just launched and are currently in beta. Join us as we build and grow the community.

Change Page Title and Meta Tags using Code behind.

Alex10

Bounce Rate Optimizer
A Rep
0
0
0
Rep
0
A Vouches
0
0
0
Vouches
0
Posts
154
Likes
93
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Submitted by
planetsourcecode

on
Sat, 06/06/2009 - 20:43

One of the good things about the asp.net is that we can make everything accessible at runtime.Same can be done with Page title and the Meta Tags.
Simply add Runat="server" to the html tag to make it accessible at run time

like below
For title

Initial Title Here

For Meta Tags

In the code Behind file:
1). Add the namespace

using system.Web.UI.HTMLControls

2). Add the following code in "OnLoad" event

title.InnerText = "Initial Title Here"
keywords.Attributes("content") = "Initial,keywords,here"
description.Attributes("content") = "This is the initial text for description meta tag"

save the change and load the page in browser and simply check the source codes of the web page.

About the author:

Planet Source Code is a place for all developer providing free source codes, articles, complete projects,complete application in PHP, C/C++, Javascript, Visual Basic, Cobol, Pascal, ASP/VBScript, AJAX, SQL, Perl, Python, Ruby, Mobile Development

 

452,292

323,526

323,535

Top