如何使用js和asp.net更改复选框

时间:2019-06-03 16:52:05

标签: javascript c# asp.net

我希望您能为我提供帮助,我正在asp.net中开发表格,但是当文本在文本框上更改时,我想激活一个复选框来激活用于更新的标志,而我使用JS进行检查,但是当我尝试时要从看起来未经检查的C#代码进行更新,有一种无需使用AutoPostaback即可进行检查的方法,因为它有很多文本框,并且当其中一项更改时,应激活检查。

这是我的asp代码

    <div class="panel panel-default letra" id="PanelDatosGenerales">
    <div class="panel-body">
        <div class="container-fluid text-center">
            <!--INICIO TITULO DE PANEL DATOS GENERALES-->
            <div class="row text-left">
                <label class="control-label" for="txtRegRecNombre">
                    <span class="form-text">DATOS GENERALES:</span>
                </label>
                <asp:CheckBox Enabled="false" Style="float:right" runat="server" ID="checkDatos1" />
            </div>
            <!--FIN TITULO DE PANEL DATOS GENERALES-->
            <!--INICIO PRIMERA FILA DE DATOS GENERALES-->

            <div class="row">
                <div class="col-sm-4">
                     <label class="control-label" for="txtRegRecNombre">
                         <span class="form-text">Nombre(s):</span>
                         </label><asp:RadioButton GroupName="Busqueda" ID="radioNombre" runat="server" Style="float:right" OnCheckedChanged="habilitarDrop" AutoPostBack="true" /><br />
                    <asp:RequiredFieldValidator id="NombreReq" runat="server"
                                                  ControlToValidate="txtRegRecNombre"
                                                  Display="Dynamic"
                                                  ValidationGroup="DatosGenerales"
                                                  ErrorMessage="Campo Obligatorio."
                                                  ForeColor="Red"></asp:RequiredFieldValidator> 
                     <asp:TextBox onchange="javascript:Changed();"  ID="txtRegRecNombre"  runat="server" CssClass="form-control ns_" MaxLength="30" minlength="5" onKeyUp="this.value = this.value.toUpperCase();" placeHolder="Nombre(s) del recurso"></asp:TextBox>

                </div>
                 <div class="col-sm-4">
                     <label class="control-label" for="txtRegRecApellidoP">
                         <span class="form-text">Apellido Paterno:</span>
                         </label><asp:RadioButton GroupName="Busqueda" ID="radioPaterno" runat="server" Style="float:right" OnCheckedChanged="habilitarDrop" AutoPostBack="true" />
                     <br />
                     <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="txtRegRecApellidoP" Display="Dynamic" ValidationGroup="DatosGenerales" ErrorMessage="Campo Obligatorio." ForeColor="Red"></asp:RequiredFieldValidator> 
                     <asp:TextBox onchange="javascript:Changed();" ID="txtRegRecApellidoP"  runat="server" CssClass="form-control ns_" MaxLength="30" onKeyUp="this.value = this.value.toUpperCase();" placeHolder="Apellido paterno del recurso"></asp:TextBox>
                 </div>
                 <div class="col-sm-4">
                     <label class="control-label" for="txtRegRecApellidoM">
                         <span class="form-text">Apellido Materno:</span>
                         </label><asp:RadioButton GroupName="Busqueda" ID="radioMaterno" runat="server" Style="float:right" OnCheckedChanged="habilitarDrop" AutoPostBack="true" />
                     <asp:TextBox onchange="javascript:Changed();" ID="txtRegRecApellidoMaterno"  runat="server" CssClass="form-control ns_" MaxLength="30" onKeyUp="this.value = this.value.toUpperCase();" placeHolder="Apellido materno del recurso"></asp:TextBox>
                 </div>

            </div>
            <br />
            <!--FIN PRIMERA FILA DE DATOS GENERALES-->
            <!--INICIO SEGUNDA FILA DE DATOS GENERALES-->
            <div class="row">
                <div class="col-sm-3">
                     <label class="control-label" for="txtRegRecRFC">
                         <span class="form-text">RFC:</span>
                         </label><asp:RadioButton GroupName="Busqueda" ID="radioRFC" runat="server" Style="float:right" OnCheckedChanged="habilitarDrop" AutoPostBack="true"  /><br />
                     <asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ControlToValidate="txtRegRecRFC" Display="Dynamic" ValidationGroup="DatosGenerales" ErrorMessage="Campo Obligatorio." ForeColor="Red"></asp:RequiredFieldValidator> 
                     <asp:TextBox onchange="javascript:Changed();" ID="txtRegRecRFC"  runat="server" CssClass="form-control ns_" MaxLength="13" onKeyUp="this.value = this.value.toUpperCase();" placeHolder="RFC del recurso"></asp:TextBox>
                 </div>
                <div class="col-sm-3">
                     <label class="control-label" for="txtRegRecCURP">
                         <span class="form-text">CURP:</span>
                    </label><asp:RadioButton GroupName="Busqueda" ID="radioCURP" runat="server" Style="float:right" OnCheckedChanged="habilitarDrop" AutoPostBack="true" /><br />
                    <asp:TextBox onchange="javascript:Changed();" ID="txtRegRecCURP"  runat="server" CssClass="form-control ns_" MaxLength="18" onKeyUp="this.value = this.value.toUpperCase();" placeHolder="CURP del recurso"></asp:TextBox>
                 </div>
                 <div class="col-sm-3">
                     <label class="control-label" for="txtRegRecIMSS">
                         <span class="form-text">Numero de IMSS:</span>
                         </label><asp:RadioButton GroupName="Busqueda" ID="radioIMSS" runat="server" Style="float:right" OnCheckedChanged="habilitarDrop" AutoPostBack="true" /><br />
                     <asp:TextBox onchange="javascript:Changed();" ID="txtRegRecIMSS" runat="server" CssClass="form-control ns_" MaxLength="10" onKeyUp="this.value = this.value.toUpperCase();" placeHolder="IMSS del recurso"></asp:TextBox>
                 </div>
                 <div class="col-sm-3">
                     <label class="control-label" for="DdlEstadoCivil">
                         <span class="form-text">Estado Civil:</span>
                     </label><asp:DropDownList  ID="DdlEstadoCivil" runat="server" CssClass="form-control ns_">
                         <asp:ListItem Selected="True" Value="-99">-- Selecciona --</asp:ListItem>

                     </asp:DropDownList>

                 </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                     <label class="control-label" for="btnRegRecAgregar">
                         <br />
                     </label>
                    <br />
                    <asp:Button ID="Button7" ValidationGroup="DatosGenerales" runat="server" class="btn btn-primary" Text="Cargar" Style="float:right" OnClick="cargarTablas"/>
                </div> 
            </div>
            <!--FIN SEGUNDA FILA DE DATOS GENERALES-->  
        </div>
    </div>
</div>

这是我的JS代码

<script  type="text/javascript">
        function Changed()
        {
            var check = document.getElementById('<%=checkDatos1.ClientID %>');
            check.checked = true;
        }
</script>

当我使用此功能“ cargarTablas”来打印支票“ checkDatos1”的值时,它显示为假

0 个答案:

没有答案