How to set Title and description of Page

Posted by Sushant under ASP.NET on 7/15/2013 | Points: 10 | Views : 1411 | Status : [Member] | Replies : 1
How to set title and description and keyword of Page:-

I Have one way can any one suggest other way

Required Name space
using System.IO;


Calling of Functions:
updatePageTitle(DevNameStr);
updatePageKeywords(DevKeywords);
updatePageDescription(DevDescription);

Function For Updating title,Key words And Meta description


private void updatePageTitle(string tempTitle)
{
if (tempTitle.ToString().Trim().Length > 0)
{
Page.Title = "Delhi Residential :: " + tempTitle.ToString();
}
else
{
Page.Title = "Delhi Residential :: Flats :: Builder Floors";
}
}
private void updatePageKeywords(string tempKeywords)
{
HtmlMeta hmKeywords = new HtmlMeta();
hmKeywords.Name = "keywords";
if (tempKeywords.ToString().Trim().Length > 0)
{
hmKeywords.Content = "Delhi Residential, Flats, Independent Houses, sale, rent, North Delhi, real estate organization, Suraj Real Estates";
}
else
{
hmKeywords.Content = "Delhi Residential, Flats, Independent Houses, sale, rent, North Delhi, real estate organization, Suraj Real Estates";
}
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(hmKeywords);
}
private void updatePageDescription(string tempDescription)
{
HtmlMeta hmDescription = new HtmlMeta();
hmDescription.Name = "description";
if (tempDescription.ToString().Trim().Length > 0)
{
hmDescription.Content = "SURAJ REAL ESTATE has successfully assembled multi-disciplinary teams of highly qualified professionals, each with many years of relevant experience in domestic as well as international markets.";
}
else
{
hmDescription.Content = "SURAJ REAL ESTATE has successfully assembled multi-disciplinary teams of highly qualified professionals, each with many years of relevant experience in domestic as well as international markets.";
}
HtmlHead head = (HtmlHead)Page.Header;
head.Controls.Add(hmDescription);
}

Sushat


Responses

Posted by: Venkat0454 on: 7/15/2013 [Member] Starter | Points: 25

Up
0
Down

protected void Page_Load(object sender, EventArgs e)
{
updatePageTitle("venkat");
updatePageKeywords("DevKeywords");
updatePageDescription("DevDescription");
}

private void updatePageTitle(string tempTitle)
{
if (tempTitle.ToString().Trim().Length > 0)
{
Session["aaa"]= tempTitle.ToString();
}
else
{
Session["aaa"]= "Flats :: Builder Floors";
}
}
private void updatePageKeywords(string tempKeywords)
{
if (tempKeywords.ToString().Trim().Length > 0)
{
Session["bbb"] = "Delhi Residential, Flats, Independent Houses, sale, rent, North Delhi, real estate organization, Suraj Real Estates";
}
else
{
Session["bbb"] = "Delhi Residential, Flats, Independent Houses, sale, rent, North Delhi, real estate organization, Suraj Real Estates";
}
}
private void updatePageDescription(string tempDescription)
{
if (tempDescription.ToString().Trim().Length > 0)
{
Session["ccc"] = "SURAJ REAL ESTATE has successfully assembled multi-disciplinary teams of highly qualified professionals, each with many years of relevant experience in domestic as well as international markets.";
}
else
{
Session["ccc"] = "SURAJ REAL ESTATE has successfully assembled multi-disciplinary teams of highly qualified professionals, each with many years of relevant experience in domestic as well as international markets.";
}
}



<head runat="server">

<title>
Delhi Residential : <%=Session["aaa"].ToString()%>
</title>
<script type="text/javascript">

</script>
<meta name="keywords" content="<%=Session["bbb"].ToString()%>">
<meta name="description" content="<%=Session["ccc"].ToString()%>" />
</head>


Sushant, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response