[Webinar] Streamline your web hosting managementRegister Today


How do I get Textbox contents in "code behind" to reflect current "on screen" contents

Posted on 2008-02-10
Medium Priority
Last Modified: 2013-11-26
I am working on a web app using AJAX and the problem is:

Page uses an AJAX control toolkit tabcontainer with two tabs

Tab1 contains a gridview with a list of records

Tab2 contains text boxes reflecting the field contents of the currently selected gridview record on Tab1

All works fine for reflecting the proper contents in the text boxes when the record in the gridview is changed (text boxes not bound... contents updated when the gridview changes using code behind).  For example in the code behind in the index changed event of the gridview, I have code like

Textbox1.Text = (appropriate gridview row/cell text)

This appears to work fine.

There is a webcontrols.button control to "Add" a new record.  This button blanks the fields and positions on the textbox for entering new data, again, using code behind.  For example, in the code behind in the click event of this button, I have code such as:

Textbox1.Text = ""

 I have set a break point in this code and the textboxes reflect the "new blank values" appropriately.

There is a "Save" button for saving the new data.
When I use the click event of the save button to prepare a SQL query for inserting a new record, the textboxes reflect the original content before blanking instead of the "new" data I entered.

What am I missing about the behavior of AJAX and code behind.... It appears the textboxes contain the original information displayed when the form was first loaded, even though I have performed changes to them on the page.
Question by:jimnorth
1 Comment

Accepted Solution

jimnorth earned 0 total points
ID: 20861629
Okay, never mind.... duh!  My PageLoad code that initially populates was NOT surrounded by an

if not is postback.....

Sorry all

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question