Accessing the same object in different events
<p>I want to have an array of objects that is shared between two different methods.</p>

<p>The onclick for button1 on my webpage calls method1, which populates the needed values for the objectArray. I need the onclick method for button2 to be able to access the same objectArray with the same data that method1 was working with.</p>

<pre><code>using myWebReference;
{
public partial class _Default : System.Web.UI.Page
{        
    ObjectArray[] myObjects = new ObjectArray[100]; 

    public void Page_Load(object sender, EventArgs e)
    {   
        //I have nothing in here at the moment      
    }
    public void method1(object sender, EventArgs e)
    {
        //myObjects[]'s values are calculated and assigned here. 
    }
    public void method2(object sender, EventArgs e)
    {
        String key = myObjects[0].value;
        //when I try to get data within myObjects here, myObjects does exist, 
    //but it is empty and I get a null reference error when I try to use its values.
    }
}       
</code></pre>
