title: How to access controls and variables, across Class and Code-behind?
body: <p>i have ASP.NET page, its code-behind, and a Class file:<br><br></p>
  
  <ul>
  <li><strong>Folder1/page.aspx (asp.net page)</strong>, it contains a <code>label</code>:</li>
  </ul>
  
  <pre class="lang-asp.net prettyprint-override"><code>   &lt;asp:Label runat="server" ID="Label1" Visible="false"&gt;&lt;/asp:Label&gt;
  </code></pre>
  
  <ul>
  <li><strong>Folder1/page.aspx.vb (code-behind)</strong>, it calls connection.vb like this:</li>
  </ul>
  
  <pre class="lang-vb prettyprint-override"><code>    Dim x As New Connection
      Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
      x.checkusernameExists(TextBoxUsername.Text)
      ' I try to access `Boolean variable` Flag from Class file but I can't.
      End Sub
  </code></pre>
  
  <ul>
  <li><strong>App_Code/connection.vb (a class file that i created)</strong>:<br></li>
  </ul>
  
  <pre class="lang-vb prettyprint-override"><code>    Public Class Connection
         Public Sub checkusernameExists(ByVal username1 As String)
         Dim flag as Boolean
         ' I try to access here `Label1.text` &amp; `Label1.visible` to work on it but I can't.
         End Sub
      End Class
  </code></pre>
  
  <p><br></p>
  
  <h2>My Questions</h2>
  
  <p>1 - <strong>How can I access the <code>Label1</code> from the <code>ASP.NET page</code> in <code>Connection.vb</code>?</strong></p>
  
  <p>2 - <strong>How can I access the <code>Boolean variable</code> from <code>Connection.vb</code> in <code>page.aspx.vb</code></strong> (code behind)<strong>?</strong></p>
  
  <p>I am really stuck in this.<BR>
  Thank you.</p>