0

我试图在处理过程中禁用 ASP.NET 页面上的控件。为此,我采用了这里的解决方案,沿着 DOM 树运行并禁用所有子控件。这适用于我尝试禁用的屏幕的许多部分,但尝试禁用一些充满控件的表格会产生以下错误:-

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 

这些都不在应用程序代码中,所以我不知道该怎么做。有谁知道如何解决问题的原因,或者我应该从哪里开始寻找?

或者,是否有更好的方法来禁用控件组?

我还尝试了这里建议的方法来禁用控件,方法是创建一个面板并将启用设置为false,但这似乎没有任何作用。

编辑:根据要求,这是旨在禁用控件的 Javascript:

    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;
    }

DisableControls函数的第一行工作正常;第二个导致错误。用第三行替换第二行以尝试替代方法没有任何作用。

ASP 中的转换变量表是这样开始的......

<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>

等等。

导致问题的表太大,无法放在这里,但包含相同类型的东西;我无法运行导致困难的特定控件。

4

1 回答 1

0

经过大量调查后,我发现如果尝试使用 Javascript 禁用ComponentArt:NumberInput未定义​​值的控件,则会引发此错误。

ComponentArt:NumberInput在发布之前为页面上的所有控件设置值可以解决错误。

于 2011-11-24T11:36:02.617 回答