I am working on a project and I found that the Session transferred value not being displayed in Label on first click. On clicking the button for the second time only the Session transferred value is being displayed. The sample code is below please let me know how to get the value displayed on the first click. Note: Value to be displayed inside the IsPostBack function as I am using lots of functions inside IsPostBack
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string kitty = Convert.ToString(Session["ping"]);
Label1.Text = kitty;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string a = TextBox1.Text;
Session["ping"] = a;
}
I think I just figured how what you mean. You need to do this.
PreRenderoccurs after the button click and will pick up the new value.