UpdatePanel control loses ViewState data if Visible property setOptions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dwight Johnson

    #1

    UpdatePanel control loses ViewState data if Visible property setOptions

    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:

    txtSecurityDepo sitDueDate.Visi ble =
    (ddlSecurityDep ositDueOn.Selec tedValue.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?
Working...