0

我有一个复选框,看起来像:

<input id="chkSelectAll" name="chkSelectAll" type="checkbox"/>

现在在一个按钮中,我希望能够隐藏该控件到目前为止我有:

chkSelectAll.Visible = false;

但我无法访问该控件的属性,因为它是客户端。

我也不能使用服务器端复选框,所以不建议这样做。

任何帮助我如何使'false'的复选框属性可见,谢谢。

4

2 回答 2

1

您可以使用 control.Attributes 或 control.Styles 在服务器端更改 DOM 属性

在后面的服务器端代码上使用 DOM 元素属性。

chkSelectAll.Styles.Add('display', 'none');

或者

chkSelectAll.Attributes.Add('style', 'display:none');

您可以在客户端ClientID的 javascript / jQuery中使用

使用 javascript

document.getElementById('<%= chkSelectAll.ClientID %>').style.display = 'none';

使用 jQuery

$('#<%= chkSelectAll.ClientID %>').hide();
于 2013-10-08T10:30:14.263 回答
0

If your checkbox is not a server control but just a client control, then what you can do is to change the styles of this checkbox: display: none you can do it with jQuery , for example. Something like this: $("#chb").css("display", "none"); You should put this functionality into some function and call it from your client side when, for example, you click on a button

于 2013-10-08T13:23:41.463 回答