UpdatePanel control loses ViewState data if Visible property set

D

Dwight Johnson

I am just starting to use AJAX, and I've run into a problem that I
cannot resolve. I have a text box, the third of three controls in an
UpdatePanel. Here's the scenario:

1. I create all the controls within the Init process.
2. Within the Load process I do FindControls on all the controls in
the page.
3. If not IsPostBack, I load data into the controls from the
database.
4. Finally, also within Load, I set the visibility of various controls
based on the requirements of the application.

The particular TextBox that I am having problems with gets a date
loaded from the database by default, but it is made Visible only if a
certain value is selected in the neighboring DropDownList, the second
control in the same UpdatePanel. This DropDownList is AutoPostBack and
triggered.

The problem is that, when the DropDownList changes to the value that
should make the TextBox Visible, the ViewState data is not entered in
the TextBox if, and only if, the following line (which runs within the
Load process) is uncommented in the code:

txtSecurityDepositDueDate.Visible =
(ddlSecurityDepositDueOn.SelectedValue.Trim() == "DO") ? true : false;

If this line is commented, the TextBox has the proper content from
ViewState; but if it runs, the TextBox is empty.

Anyone? Anyone?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top