Note that there are some explanatory texts on larger screens.

plurals
  1. POSession State will not update
    primarykey
    data
    text
    <p>I am trying to write a page in asp.net to update an user object from Session state and I am running into a problem putting the object back into the Session state</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text.RegularExpressions; public partial class UpdateAccount : System.Web.UI.Page { cAccount account; protected void Page_Load(object sender, EventArgs e) { if (Session["account"] != null) { account = (cAccount)Session["account"]; lblID.Text = account.AccountNumber.ToString(); txtEmail.Text = account.Email; txtFirstName.Text = account.FirstName; txtLastName.Text = account.LastName; lblArtist.Text = account.Artist.ToString(); if (account.CardNumber != "") { ddlCardType.SelectedValue = account.CardType; txtNumber.Text = account.CardNumber; ddlMonth.SelectedIndex = (account.ExpMonth - 1); txtExpYear.Text = account.ExpYear.ToString(); } else { ddlCardType.SelectedIndex = 0; txtNumber.Text = ""; ddlMonth.SelectedIndex = 0; txtExpYear.Text = ""; } } else { lblID.Text = "-1"; txtEmail.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; lblArtist.Text = ""; ddlCardType.SelectedIndex = 0; txtNumber.Text = ""; ddlMonth.SelectedIndex = 0; txtExpYear.Text = ""; } } protected void btnUpdateUser_Click(object sender, EventArgs e) { if (txtOldPass.Text == account.Password) { lblOldPass.Text = ""; account.setDetails(txtEmail.Text, txtFirstName.Text, txtLastName.Text); Session["account"] = account; Response.Redirect("Accounts.aspx"); } else { lblOldPass.Text = "Password Incorrect"; } } } </code></pre> <p>This is the code i am using on load, and on update. These are the only spots session state is used. </p> <p>EDIT</p> <p>The exact problem I am getting is the updated object does not get saved to the Session State. The old one remains on page load of this page and the page I am using to display the object. The Form_Load method works the same in both.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload