title: Setting page title from @ Page directive in ASP.NET using master pages
body: <p>I am using master pages and am having trouble setting page titles from the @ Page directive.  All of my classes inherit from a class <em>myPage</em> which inherits from the ASP.NET <em>System.Web.UI.Page</em> class. <strong>Please Note:</strong> I have <strong>runat="server"</strong> set in my master page's head tag.</p>
  
  <p>Here's what my @ Page directives look like for the file <strong>test.aspx.vb</strong>:</p>
  
  <pre><code>&lt;%@ Page language="VB" MasterPageFile="~/MainMaster.master" 
  autoeventwireup="false" CodeFile="test.aspx.vb" 
  Inherits="test" Title="test" %&gt;
  </code></pre>
  
  <p>Here's what <strong>test.aspx.vb</strong> looks like:</p>
  
  <pre><code>Partial Class test
      Inherits myPage
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
      End Sub
  
  End Class
  </code></pre>
  
  <p>This is what my master file, <strong>MainMaster.master</strong>, looks like:</p>
  
  <pre><code>&lt;%@ Master Language="VB" CodeFile="MainMaster.master.vb" Inherits="MainMaster" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head runat="server"&gt;
      &lt;title&gt;untitled&lt;/title&gt;
  &lt;/head&gt;
  ...
  </code></pre>
  
  <p>Now, when you go to view <strong>test.aspx</strong> in a browser you'd expect to see the title 'test'. but instead you will see 'untitled' as per the master page.  Through trial and error, I modified the <em>test</em> class to inherit from <em>System.Web.UI.Page</em> directly, instead of <em>myPage</em> like this:</p>
  
  <pre><code>Partial Class test
      Inherits Page
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
      End Sub
  
  End Class
  </code></pre>
  
  <p>and everything worked just fine. Why would my pages being children of <em>myPage</em> instead of <em>System.Web.UI.Page</em> prevent the title from being set correctly in the @ Page directive?</p>
  
  <p>I realize that I could just set the page titles programmatically through the <em>Page_Load</em> methods in every page, but I'd rather do it in the @ Page directives in the .aspx files.</p>
  
  <p>This is a very weird and frustrating problem, and I'm at a loss!</p>
  
  <p>Thanks!!! </p>