I am attempting to disable controls on an ASP.NET page while processing is in progress. To this end I adopted the solution from here, running down the DOM tree and disabling all the child controls. This works fine for many of the portions of the screen I am attempting to disable, but attempting to disable some tables-full of controls produces the following error:-
Server Error in '/' Application.
--------------------------------------------------------------------------------
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471479
System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) +115
System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info) +192
System.Double.Parse(String s, IFormatProvider provider) +25
ComponentArt.Web.UI.NumberInput.set_Value(Nullable`1 value) +81
ComponentArt.Web.UI.NumberInput.LoadViewState(Object savedState) +255
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
System.Web.UI.Page.LoadAllState() +312
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3625; ASP.NET Version:2.0.50727.3618
None of this is in the application code so I don't know what to do about it. Does anyone know how to go about running down the cause of the problem, or where I should start looking?
Alternatively, is there a better way of disabling groups of controls?
I have also tried the method suggested here for disabling controls, by creating a panel and setting enabled to false
, but that doesn't appear to do anything.
EDIT: as requested, here is the Javascript that is intended to disable the controls:
function disableChildElements(objId)
{
var theObject = document.getElementById(objId);
var level = 0;
TraverseDOM(theObject, level, disableElement);
}
function TraverseDOM(obj, lvl, actionFunc)
{
for (var i=0; i<obj.childNodes.length; i++)
{
var childObj = obj.childNodes[i];
if (childObj.tagName)
{
actionFunc(childObj);
}
TraverseDOM(childObj, lvl + 1, actionFunc);
}
}
function disableElement(obj)
{
obj.disabled = true;
}
function DisableControls()
{
disableChildElements(castVariablesTable.id);
disableChildElements(oldGradeTable.id);
oldGradePanel.enabled=false;
}
The first line of the DisableControls
function works fine; the second causes the error. Replacing the second line with the third line to try the alternative method does nothing.
The cast variables table in the ASP starts like this...
<table id="castVariablesTable" class="normalTable">
<tr>
<td>
<label class="normalText">Number of strands</label>
</td>
<td>
<span class="normalInput">
<MixedZone:NumberInput runat="server"
ID="niNumberOfStrands"
MaxLength="1"
Step="1"
Increment="1"
MaxValue="6"
MinValue="1"
NumberType="Number"
DecimalDigits="0">
</MixedZone:NumberInput>
</span>
and so on.
The table that causes the problem is too large to put in here but contains the same sort of stuff; I haven't been able to run down a particular control causing the difficulty.