I have read quite a few posts / articles on how to do this, and I still do not get the page title indicated on the content page. My pages display OK, except that I cannot get a set of titles on the content page (the whole page has a title set on the main page). Here is the codebehind for my main page:
Partial Class zSEO Inherits System.Web.UI.MasterPage Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Page.Header.Title = "Dynamically set in Master page" End Sub End Class
Here is the rest of the main page:
<%@ Master Language="VB" EnableTheming="true" Inherits="zSEO" CodeFile="zSEO.master.vb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div id="container"> <div id="content"> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </div> </form> </body> </html>
However, it is on the web content page that I want to set the value for the page, and I placed it on my test content page:
Public Partial Class zShowAd Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Page.Header.Title = "Dynamically set TITLE value in the content(child) page" End Sub End Class
Strange, I canβt get the debugger to stop on the line above on the content page - only on the corresponding line of the main page. It is clear that I am confused by this.
I read that there are other ways to do this, but it seemed possible from what I read in Scott Mitchell's tutorial: Dynamically adjusting the page title in ASP.NET . In particular, I tried to follow this from the article: "In addition, if you use master pages, this code can work, as it is written, from the main page or ASP.NET page using the main page. In this scenario, the region should be defined on the main page, but the ASP.NET page can still access it through the PageHeader page. "
John adams
source share