Problems updating a textBox ASP.NET

Posted by Roger Filipe on Stack Overflow See other posts from Stack Overflow or by Roger Filipe
Published on 2010-06-01T23:38:44Z Indexed on 2010/06/01 23:43 UTC
Read the original article Hit count: 243

Filed under:
|

Hello, I'm starting in asp.net and am having some problems that I do not understand. The problem is this, I am building a site for news. Every news has a title and body. I have a page where I can insert news, this page uses a textbox for each of the fields (title and body), after clicking the submit button everything goes ok and saves the values in the database. And o have another page where I can read the news, I use labels for each of the camps, these labels are defined in the Page_Load. Now I'm having problems on the page where I can edit the news. I am loading two textboxes (title and body) in the Page_Load, so far so good, but then when I change the text and I click the submit button, it ignores the changes that I made in the text and saves the text loaded in Page_Load.

This code doesn't show any database connection but you can understand what i'm talking about.

protected void Page_Load(object sender, EventArgs e)
    {           
        textboxTitle.Text = "This is the title of the news";       
        textboxBody.Text = "This is the body of the news ";        
    }

I load the page, make the changes in the text , and then click submit.

protected void btnSubmit_Click(object sender, EventArgs e)
    {
        String title = textboxTitle.Text;        
        String body = textboxBody.Text;
        Response.Write("Title: " + title + " || ");
        Response.Write("Body: " + body );
    }

Nothing happens, the text in the textboxes is always the one I loaded in the page_load, how do I update the Text in the textboxes?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about textbox