0
I have the following code:
Admin Page:
private void Salvar()
{
Session.Add("Salvar", txtSobre.Text);
try
{
if (txtSobre.Text != string.Empty)
{
Session["Salvar"] = txtSobre.Text.Trim();
}
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
protected void btnSobre_Click(object sender, EventArgs e)
{
Salvar();
}
User page:
private void Atualizar()
{
try
{
lblSobre.Text = Session["Salvar"].ToString();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
protected void btnAtualizar_Click(object sender, EventArgs e)
{
Atualizar();
}
And I can’t seem to get a text out of TextBox
to the label of the other page. Gives the following error:
Undefined object reference for an object instance.
First check if the directives, if I’m not mistaken the correct directive is System.Web.UI. Also try to debug, place a breakpoint exactly on the line that is receiving the Session value, position the mouse above the Session and check that the value it is receiving is the desired one.
– Brenno Segolim
It is important that you treat this data, mainly because it comes by session. In what posted in the question there is no problem, you have to evaluate if the session is being lost/cleaned in your application for some reason while loading the user page.
– George Wurthmann
@Maisaberlofa See my answer and confirm that this was your problem.
– Leandro Angelo