I have this:
protected void Page_Load(object sender, EventArgs e)
{
nome_Txt.Text = Profile.dados_pessoais.nome;
}
protected void save_Click(object sender, EventArgs e)
{
Profile.dados_pessoais.nome = nome_Txt.Text;
}
If Profile.dados_pessoais.nome is empty, nome_txt.Text is empty too. When I change nome_Txt.Text to teste for example, when I click on the button nome_Txt.Text is empty.
What am I doing wrong?
The
Page_Loadevent run before the button click event so you always assign the text box to empty value.To solve this, don’t populate the textbox when you are in a Postback:
As also stated in a comment, you probably have to save the profile after changing it otherwise it won’t be saved when you next load the page: