I have a variable which I have declared outside all methods/functions:
public partial class page : System.Web.UI.Page
{
string query;
protected void btn_1_Click(object sender, EventArgs e)
{
query = "hi";
query = query + "how are you";
}
protected void btn_2_Click(object sender, EventArgs e)
{
string newquery = query;
}
}
When I debug this in the btn_2_Click
when it has been fired it says the query variable is null. I am trying to access the query made from btn_1
in btn_2
.
What is the best way to do this? Or am I doing something wrong?