Javascript 获取服务器标记不是格式正确的错误 函数EnableDisablePkgInclusionDropDown(chkBox,索引){ 警报(“行索引:”+(索引-1)); var repeater=document.getElementById(“”); var dropdowns=repeater.getElementsByTagName('select'); 如果($(chkBox).is(':checked')){ 下拉列表[索引-1]。禁用=真; 下拉列表[索引-1]。selectedIndex=document.getElementById(“”)。selectedIndex; } 否则{ 下拉列表[索引-1]。已禁用=false; 下拉列表[索引-1]。选择了索引=“0”; } }

Javascript 获取服务器标记不是格式正确的错误 函数EnableDisablePkgInclusionDropDown(chkBox,索引){ 警报(“行索引:”+(索引-1)); var repeater=document.getElementById(“”); var dropdowns=repeater.getElementsByTagName('select'); 如果($(chkBox).is(':checked')){ 下拉列表[索引-1]。禁用=真; 下拉列表[索引-1]。selectedIndex=document.getElementById(“”)。selectedIndex; } 否则{ 下拉列表[索引-1]。已禁用=false; 下拉列表[索引-1]。选择了索引=“0”; } },javascript,repeater,Javascript,Repeater,如果我从复选框中删除runat=“server”,则其工作正常,但我希望此控件的值在代码隐藏中 为什么会这样 提前感谢使用类似的东西 <script type="text/javascript" language="javascript"> function EnableDisablePkgInclusionDropDown(chkBox,index) { alert("RowIndex: " + (index - 1)

如果我从复选框中删除runat=“server”,则其工作正常,但我希望此控件的值在代码隐藏中

为什么会这样


提前感谢

使用类似的东西

        <script type="text/javascript" language="javascript">
        function EnableDisablePkgInclusionDropDown(chkBox,index) {
                alert("RowIndex: " + (index - 1));
                var repeater = document.getElementById('<%= pnlrptPckgInclusions.ClientID %>');
                var dropdowns = repeater.getElementsByTagName('select');
                if ($(chkBox).is(':checked')) {
                    dropdowns[index - 1].disabled = true;
                    dropdowns[index - 1].selectedIndex = document.getElementById('<%=ddlMarkUpBasis.ClientID%>').selectedIndex;
                }
                else {
                    dropdowns[index - 1].disabled = false;
                    dropdowns[index - 1].selectedIndex = "0";
                }
            }
        </script>

    <asp:Repeater runat="server" ID="rptPckgInclusions">      
    <ItemTemplate> 
<td align="center" style="width: 20%;">
        <input type="checkbox" runat="Server"  ID="chkApplyParentMarkUp" OnClick='EnableDisablePkgInclusionDropDown(this,<%#DataBinder.Eval(Container.DataItem, "ID") %>);' />
</td>
    </ItemTemplate> 
    </asp:Repeater>


因为您不能将输入类型复选框定义为
runat=“server”
。并代表
onClick
事件使用
OnCheckedChanged
事件。

它不起作用。在警报中不显示任何内容(“行索引:”+(索引-1));
<asp:CheckBox runat="server" ID="chkApplyParentMarkUp" OnCheckedChanged='EnableDisablePkgInclusionDropDown(this,<%#DataBinder.Eval(Container.DataItem, "ID") %>);' />