Disabling a drop-down loses the selected value

T

teddysnips

VS2003, SP1

I have a "finder" form which consists of a bunch of criteria controls
(text boxes, drop downs, check boxes etc.) and a couple of buttons
(Search, and Cancel).

When you check one of the check boxes (which does a postback), the
code behind loads a different page based on the value of one of the
drop-downs. However, loading this new page takes a while, because it
involves some very, very hairy SQL. The client reports that users are
in the habit of changing values on the first page (the finder form)
while the new page loads. The client has asked me to disable the
criteria controls while the new page loads.

Here's how I've approached it.

1. I've attached a javascript function (fubar, shown below) to the
onclick event of the check box (for some reason I get a 500 error if I
try to attach it to an OnCheckChanged event.)

2. The javascript function disables the controls and then does a
postback on the check box

3. The code behind looks for the value in the selected drop-down and
attempts to load the new page based on the selected value.

// Get document element
function getE(id) {
return document.getElementById(id);
}

function fubar() {
chk = getE('chkDataVariance');
if (chk.checked == true)
{
// disable a whole bunch of other controls, omitted
for clarity
getE('cboMyDropDown').disabled = true; <---- THIS
IS THE PROBLEM
__doPostBack('<%=chkDataVariance.ClientId %>' ,'');
}
}

If I comment out the line getE('cboCourt').disabled = true;, the code
works but the drop-down can still be changed by the user. If I leave
the line as it is, in the code behind the If condition evaluates
false:

Private Sub chkDataVariance_CheckedChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
Handles chkDataVariance.CheckedChanged

If Me.chkDataVariance.Checked = True Then
If Me.cboMyDropDown.SelectedValue <> "" Then <---- THIS
CONDITION IS FALSE

' Open DataVariance form
SearchForm.ProcessCommand(Me.dgSearch, "New", 0,
PageNavigation.PageID.DataVariance,
Me.cboMyDropDown.SelectedValue)
Else
WebHelper.DisplayClientMessage(Me, "err", "A Value
must be specified for My Drop Down")
Me.chkDataVariance.Checked = False
End If
End If

End Sub

What I want to know is WHY does disabling a control mean that it loses
its value? I've tested this with other controls on the form - it's
also true for textboxes. Viewstate is enabled both on the page and on
the control.

Thoughts?

Edward
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top