title: ASP.net writing code behind variable to HTML page code
body: <p>Hey all i am trying to get this:</p>
  
  <pre><code>&lt;div id="subpg_main"&gt;    
  &lt;%= theHeadering %&gt;
  &lt;/div&gt;
  &lt;!-- END BODY PAGE -------------------------&gt;
  </code></pre>
  
  <p>To work within my HTML code.</p>
  
  <p>The code behind just has this:</p>
  
  <pre><code>Public Class thankyou
      Inherits System.Web.UI.Page
      Public theHeadering As String = ""
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          Dim theName As String = "Bob Barker"
          Dim theEmail As String = "bobb@thepriceisright.com"
  
          If theForm = "contact" Then
              theHeadering = "&lt;H1&gt;Thank you " &amp; theName &amp; " for contacting us!&lt;/H1&gt;&lt;BR /&gt;"
              theHeadering += "We will be contacting you via your email address at " &amp; theEmail &amp; " within 24 hours."
          End If
      End Sub    
  End Class
  </code></pre>
  
  <p>However, when i run the page i get the following error:</p>
  
  <p><strong>Compiler Error Message: BC30451: 'theHeadering' is not declared. It may be inaccessible due to its protection level.</strong></p>