你好,有谁知道如何启用和禁用一个空洞div内容。我有一个div有一个celendar和文本框以及下拉列表等...我想当用户按下一个按钮,div内的内容被禁用,请注意我不想让它们隐形但启用或禁用。现在我知道我可以使每个文本框日历等..单独禁用但我想知道是否有办法使洞div内容禁用,从而节省一些行代码和时间。谢谢这里是div的内容代码:
<asp:Calendar ID="mtcDataMR" runat="server" onselectionchanged ="mtcDataMR_SelectionChanged" ></asp:Calendar>
<br />
<asp:TextBox ID="txtData" runat="server" ReadOnly="True"></asp:TextBox>
<br />
</fieldset>
<fieldset>
<legend>Filtrar Marcações</legend>
<br />
Nome de Utente<br />
<asp:CheckBox ID="chkFiltroUtente" text=" " runat="server" AutoPostBack="true" OnCheckedChanged="chkFiltroUtente_CheckedChanged" /><asp:TextBox ID="txtFiltrarNomeUtente" runat="server" AutoPostBack="true" OnTextChanged="txtFiltrarNomeUtente_TextChanged" ReadOnly="True" ></asp:TextBox>
<br />
<br />
<fieldset>
<legend>Tipo de Marcações a Mostrar</legend>
<asp:RadioButton ID="rdbConsultas" text="Consultas" runat="server" GroupName="rdb" AutoPostBack="true" OnCheckedChanged="rdbTratamentos_CheckedChanged" />
<asp:RadioButton ID="rdbTratamentos" text="Tratamentos" runat="server" GroupName="rdb" Autopostback ="true" Checked="True" />
</fieldset>
<br />
Nome de Especialista<br />
<asp:CheckBox ID="chkFiltroEspecialista" Text=" " runat="server" /> <asp:DropDownList runat="server" ID="cbxFiltroEspecialista" OnSelectedIndexChanged ="cbxFiltroEspecialista_SelectedIndexChanged" AutoPostBack="true" /> <br />
Local de Tratamento<br />
<asp:CheckBox ID="chkFiltroLocal" Text=" " runat="server" /> <asp:DropDownList runat="server" ID="cbxLocal" OnSelectedIndexChanged ="cbxFiltroLocal_SelectedIndexChanged" AutoPostBack="true" /> <br />
Hora de Inicio<br />
<asp:CheckBox ID="chkFiltroHora" Text=" " runat="server" /> <asp:DropDownList runat="server" ID="cbxFiltroHora" OnSelectedIndexChanged ="cbxFiltroHora_SelectedIndexChanged" AutoPostBack="true" /> <br />
<fieldset>
<legend> Estados a Apresentar</legend>
<asp:CheckBox ID="chkMRSuspensas" runat="server" text="Mostrar Marcações Suspensas" AutoPostBack ="true" OnCheckedChanged="chkMRSuspensas_CheckedChanged"></asp:CheckBox>
<br />
<asp:CheckBox ID="chkMRCanceladas" runat="server" text="Mostrar Marcações Canceladas" AutoPostBack="true" OnCheckedChanged="chkMRSuspensas_CheckedChanged"></asp:CheckBox>
</fieldset>
<asp:Button text="Limpar Filtros" ID="btnFiltroClear" runat="server" OnClick="btnFiltroClear_Click" />
</fieldset>
</div>
btw我目前正在使用的是(按钮点击)
mtcDataMR.Enabled = False
txtData.Enabled = False
chkFiltroUtente.Enabled = False
rdbConsultas.Enabled = False
rdbTratamentos.Enabled = False
chkFiltroEspecialista.Enabled = False
chkFiltroLocal.Enabled = False
chkFiltroHora.Enabled = False
chkMRSuspensas.Enabled = False
chkMRCanceladas.Enabled = False
btnFiltroClear.Enabled = False
cbxFiltroEspecialista.Enabled = False
cbxLocal.Enabled = False
cbxFiltroHora.Enabled = False
但是你可以看到代码行很多。
答案 0 :(得分:1)
您可以启用或禁用div。写在div runat =&#34; server&#34;和id =&#34;一个id名称&#34; 。然后,您可以访问.cs页面中的div id。现在您可以启用或禁用。
示例:
.aspx页面:
<div runat="server" id="divSearch"> {here you write} </div>
.aspx.cs页面:
divSearch.enable = false; OR divSearch.enable = true;