I know this is a simple question but its been driving me nuts. I figure I'll ask here since another pair of eyes will see what I'm missing.
I'm just learning asp.net using C# and trying different things out to see how it works. I'm now trying to pass session variables between two pages.
On webform1.aspx I have just a button that is used to call a popup page and here is the code under the Page_Load
I have now created an Onclick attribute for the button and I have added this code when I press the button:
I know the setting session to null and removing is a bit extreme but the problem I'm having is I have added another button and has the same bit of coding as I have posted above with the exception the sql is a different one.
When I run it and press button1 it loads the page up with the data with no problems. When I press the second button it still is holding the old sql statement instead of passing my new one. I close the popup window and press the second button again and it will load the page correctly.
So am I missing something like needing to set a setting on the forms that may not be set correctly or is their a problem using the same session variable name.
Any help or suggestions will be greatly appreciated. Have a great day.
I'm just learning asp.net using C# and trying different things out to see how it works. I'm now trying to pass session variables between two pages.
On webform1.aspx I have just a button that is used to call a popup page and here is the code under the Page_Load
Code:
this.btnEngineer.Attributes.Add("OnClick","javascript:window.open('../Popup/webform2.aspx','popup_window','toolbar=0,scrollbars=10, location=0, statusbar=0, menubar=0, resizable=1, width=500, height=500');");
I have now created an Onclick attribute for the button and I have added this code when I press the button:
Code:
private void btnEngineer_Click(object sender, System.EventArgs e)
{
Response.Write("Engineer");
Session["sql"] = null;
Session.Remove("sql");
Session["sql"] = "select em_id as Engineer from employee";
}
I know the setting session to null and removing is a bit extreme but the problem I'm having is I have added another button and has the same bit of coding as I have posted above with the exception the sql is a different one.
When I run it and press button1 it loads the page up with the data with no problems. When I press the second button it still is holding the old sql statement instead of passing my new one. I close the popup window and press the second button again and it will load the page correctly.
So am I missing something like needing to set a setting on the forms that may not be set correctly or is their a problem using the same session variable name.
Any help or suggestions will be greatly appreciated. Have a great day.