May 21, 2012

Change Page Title dynamically in ASP.NET using C#

I din't have fixed Page Titles ,I needed to add them dynamically after fetching from DB.

First I used below code to add Page Title dynamically .
  
// Response.Write("<title>" + ds.Tables[0].Rows[0][1].ToString() + "</title>");

This worked in Google Chrome , but not in IE , I looked into Page Source and the title was being added on the top before <html> tag. this was the problem IE was not letting it work .

then below code worked well to add title dynamically in all the browsers

Page.Title = ds.Tables[0].Rows[0][1].ToString();

No comments:

Post a Comment