I have the following snippet of code. When the user enters the page, there is a default value set in the text box. Now when the user changes the value and clicks a button, I am seeing the default value instead of the changed value.
Moving the code to !IsPostback block is not an option at this time. There are values coming in from the session object that need to be retained at all times.
public partial class _Default : Page
{
Models.InspectionModel model = new Models.InspectionModel();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
if (Request.QueryString.Count > 1)
{
//Create a session object.
model.Name = Request.QueryString["Make"].ToString();
model.Key = "Chrysler";
model.Id = -1;
Session["CurrentModel"] = model;
//This value needs to change
txtTest2.Text = "Hello My Name is LUKE";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
model.Id = 2;
model.Name = "Renegade";
TextBox1.Text = $"Model Information {model.Id} name - {model.Name} key - {model.Key}";
}
protected void btnCheck_Click(object sender, EventArgs e)
{
Response.Write(txtTest2.Text);
}