I dont think I'll need to post any code for my question, but if anyone would like to see just let me know and I'll post.
Here's my problem:
I have a site with an EditAccount page. I have it to where the textboxes are filled with the user's existing account info on Page_Load(). The idea is that the user would simply change any textbox to what they want updated, and once they click "save", the database row gets updated with whatever is in the textboxes when they click "save"
The problem is that after I click "save", only what was originally in the textboxes gets saved to the DB...
it doesnt seem to recognized the changes made to the textboxes.
Does anyone know any C# methods or properties that can fix this?
Thanks in advance
Saving Text Box Changes
Page 1 of 14 Replies - 1507 Views - Last Post: 28 July 2010 - 02:19 PM
Replies To: Saving Text Box Changes
#2
Re: Saving Text Box Changes
Posted 28 July 2010 - 01:31 PM
Moved to ASP.NET
When asking questions about ASP.NET please post them in the ASP.NET forum, even if you're using C# with ASP.NET
When asking questions about ASP.NET please post them in the ASP.NET forum, even if you're using C# with ASP.NET
#3
Re: Saving Text Box Changes
Posted 28 July 2010 - 01:43 PM
I think you do need to post the code in your Page_Load event. Most likely, your problem is that you aren't wrapping the code in the Page_Load with if (!Page.IsPostback). Without this if statement, the code is going to execute the database operation to get the data, then overwrite the data in the textboxes, thereby resetting data. That's why you don't see any changes.
To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.
FYI, the Page_Load method is executed on EVERY postback.
To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.
FYI, the Page_Load method is executed on EVERY postback.
This post has been edited by eclipsed4utoo: 28 July 2010 - 01:44 PM
#4
Re: Saving Text Box Changes
Posted 28 July 2010 - 01:47 PM
eclipsed4utoo, on 28 July 2010 - 12:43 PM, said:
I think you do need to post the code in your Page_Load event. Most likely, your problem is that you aren't wrapping the code in the Page_Load with if (!Page.IsPostback). Without this if statement, the code is going to execute the database operation to get the data, then overwrite the data in the textboxes, thereby resetting data. That's why you don't see any changes.
To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.
FYI, the Page_Load method is executed on EVERY postback.
To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.
FYI, the Page_Load method is executed on EVERY postback.
K, you're right, I was missing that if statement. I just added it - will post back with results
#5
Re: Saving Text Box Changes
Posted 28 July 2010 - 02:19 PM
thursdayniac, on 28 July 2010 - 12:47 PM, said:
eclipsed4utoo, on 28 July 2010 - 12:43 PM, said:
I think you do need to post the code in your Page_Load event. Most likely, your problem is that you aren't wrapping the code in the Page_Load with if (!Page.IsPostback). Without this if statement, the code is going to execute the database operation to get the data, then overwrite the data in the textboxes, thereby resetting data. That's why you don't see any changes.
To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.
FYI, the Page_Load method is executed on EVERY postback.
To test, put a breakpoint where you set one of the Textbox's text in the Page_Load. Now when you click the Save button, the breakpoint will be hit. Check the value of the text at the breakpoint, then hit F10, then check the text again. You will see what I mean.
FYI, the Page_Load method is executed on EVERY postback.
K, you're right, I was missing that if statement. I just added it - will post back with results
It worked, thanks =)
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|