I am currently working on a project where I want to allow a customer to update their details through a web interface. I am using C# codebehind. On page load I am setting the values of the textbox using the existing customers details.

The idea being, the user sees the textbox with the existing details and can make changes and click submit.

On the submit button click I have C# code which I am attempting to retrieve the changed value from the textbox control. However the textbox control seems not to have updated itself, as the value (from the textbox control) is still the existing value.

This is the code I am using on the button click event.

patient.Firstname = txtFirstname.Text.Trim();

Any help and pointers would be much appreciated.

Recommended Answers

All 3 Replies

Yo dude , you will have to give some clearer details...

Does the textbox not display the new value or does it not update the database ??

Hey thanks,

I'm not concerned with database access here, I am using a webservice to handle that part. I simply want to retrieve the value from the textbox.

For example, on load, I will change a textbox to hold the customers name, say "John". Then the user changes that value to "James" and clicks submit. On the submit button click event I want to retrieve the new value ("James") from the textbox. But when put a breakpoint in and look at the textbox text value it still holds "John".

Cheers

I have managed to solve the problem. I did not realise that when the submit button was clicked, the postback reloads the form. This caused my setup method to run and populate the textbox with the old information.

Sorry, this wasn't a technical issue, just my incompetence!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.