ASPX:
<asp:Button class="testBtn" id="testBtn" Text="Test Variable" runat="server" OnClick="test_Click"/>
C#:
protected void Page_Load(object sender, EventArgs e)
{
//Session Variables START
Session["Name"] = null;
//Session Variables END
if (!IsPostBack)
{
Session["Name"] = "tester";
}
else
{
//
}
}
protected void test_Click(object sender, EventArgs e)
{
string test1 = (string)Session["Name"];
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + test1 + "');", true);
}
Any help would be greatly appreciated. For whatever reason I cannot get the variable to stick.