# Add Title to Web Part Page Programmatically

I am using following code to create web part pages. I want to add the "title" of the page as well. I am not sure what would be the extra piece of code. My site is not a publishing site and I am not creating publishing pages just simple web part pages and adding web parts further through code only.

@"<?xml version=""1.0"" encoding=""UTF-8""?>
<Method>
<SetList Scope=""Request""><ListID></SetList>
<SetVar Name=""ID"">New</SetVar>
<SetVar Name=""Cmd"">NewWebPage</SetVar>
<SetVar Name=""Type"">WebPartPage</SetVar>
<SetVar Name=""WebPartPageTemplate""><Template></SetVar>
<SetVar Name=""Title""><PageName></SetVar>
<SetVar Name=""Overwrite"">True</SetVar>
</Method>


I would think you need to clarify your question as im kind confused at what your asking for? the page title in the webpart or the webpart title in the webpage or add a title on the page from the webpart? you also said Programmatically in c#? or SPD? or as a feature? lol sorry to be a pain :)

but if I have got you right it would be the third option and you said you want it in code only?

protected void Page_Load(object sender, EventArgs e)
{
ITitleProvider titleProvider = AxBaseWebPart.GetWebpart(this) as ITitleProvider;

// Specify the title to pass as the AxPageTitle
titleProvider.Caption = "Page title goes here";

// Do not include the context in the title
titleProvider.ShowContext = false;
}


http://msdn.microsoft.com/en-us/library/cc595967.aspx

• Ok Let me clarify it more. I am creating web part pages and adding my custom web parts at the same time on feature activation through the code I have listed. By default page name is taken as the Page Title. I am interested in setting the page title (text that appears on browser title bar). And all this should happen on feature activation.Hope it helps. – V.B Aug 17 '12 at 11:38
• iv got some links for you to check out. weblogs.asp.net/avnerk/archive/2007/04/11/… and this is hiding the title using css techtrainingnotes.blogspot.co.uk/2009/03/… – Ali Jafer Aug 17 '12 at 12:51