hi all,
I have a problem. I have a class file name Agent which has Name and
SalesPerson as two strings. On below page, am reading session object called
agentdetail of class Agent and filling out agency name and salesperson name
on page load event
public partial class AgentDetail : System.Web.UI.Page
{
Agent agentdetail = new Agent();
protected void Page_Load(object sender, EventArgs e)
{ if (Session["agentdetail"] != null)
{ agentdetail = (Agent)Session["agentdetail"];
agencyname.Text = agentdetail.Name;
asalesperson.Text = agentdetail.SalesPerson;
}}
}
Now on button called proceed, am saving agency name and sales person name
again in agentdetail object and adding it into session variable called
"agentdetail". Now if I come back to this page and change agencyname or
sales person name then its not saving changes to the new object in the
session. Eg - if I have "abc" as agency name and "myagent" as agent name
which on proceed button, I save it in session varialbe called agentdetail.
Now when I come back to page, it shows correct details and if I change sales
person name to "youragent" and them comee back to this page, it still shows
"myagent" .....
protected void proceed_Click(object sender, EventArgs e)
{ agentdetail.Name = agencyname.Text;
agentdetail.SalesPerson = asalesperson.Text;
Session.Add("agentdetail", agentdetail); // in short here it is
not replacing the agentdetail variable which is alredy stored in session.
}
I don't know where am going wrong. Pls help...........(am kinda new to c#)
here is the structure of Address class file
public class Agent
{
private string name;
private string salesPerson;
public string Name
{
get { return this.name; }
set { this.name = value; }
}
public string SalesPerson
{
get { return this.salesPerson; }
set { this.salesPerson = value; }
}
}