title: accessing variable defined and set in code behind - on aspx page
body: <p>Sorry for such a basic question. I work in C# but have to do something on a site written in vb.net</p>
  
  <p>In C# I can declare a variable and set it like this - in code behind.</p>
  
  <pre><code>public partial class _Default : System.Web.UI.Page
  {
      public string str = "Fred";
      protected void Page_Load(object sender, EventArgs e)
      {
      str = "Jim";
      }
  }
  </code></pre>
  
  <p>And, on the .aspx page, anywhere on the page I can write:</p>
  
  <pre><code>&lt;% Response.Write(str) %&gt;
  </code></pre>
  
  <p>and it will write "Jim" to the screen.</p>
  
  <p>How do you do that in vb.net? I have ...</p>
  
  <pre><code>Public Class _Default
  Inherits System.Web.UI.Page
  Public Ary As ArrayList
  Public str As String
  
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  Dim str as String
  str = "Freda"
  </code></pre>
  
  <p>If I write &lt;% Response.Write(str) %> on the .aspx page - nothing is written.</p>
  
  <p>If I write &lt;% Response.Write("Freda") %> on the .aspx page - it writes "Freda" to the screen.</p>
  
  <p>In vb.net - what do you have to do to access variables set in the code behind, on the .aspx page?</p>
  
  <p>I am not interested in setting the text value of a server control like a label etc. What I actually need to do is:</p>
  
  <p>Get a list of images from a database call and</p>
  
  <p>Build a dynamic jquery slider on the .aspx page by looping through the list of images and writing the various <li> tags and onclick events etc.</p>
  
  <p>Sometimes my slider will have 3 pictures, other times it might have 6 or 8. Could be any number between 3 and 11. But I need to build it dynamically based on data returned from a database.</p>