如果我将某个控件的属性Visible设置为“false”,那么在生成的aspx页面的HTML中,我将看不到该控件。但是,当我在该控件的style标签中使用display:none时,在HTML中我会看到该控件被灰色显示。为什么会这样呢?
另外,如果我发现页面上有一些不再需要的控件:
1. 我应该将其从页面中注释掉吗? 2. 应该将其属性设置为Visible=false吗? 3. 应该将其设置为display:none吗?
在考虑时间限制和页面负荷的情况下,哪种方法最好呢?
以下是我的测试页面生成的HTML:
另外,如果我发现页面上有一些不再需要的控件:
1. 我应该将其从页面中注释掉吗? 2. 应该将其属性设置为Visible=false吗? 3. 应该将其设置为display:none吗?
在考虑时间限制和页面负荷的情况下,哪种方法最好呢?
以下是我的测试页面生成的HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
</head>
<body>
<form id="form1" action="testvisibility.aspx" method="post" name="form1">
<div>
<input id="__VIEWSTATE" type="hidden" value="/wEPDwUKMTY2NDk3NDQzNQ9kFgICAw9kFgQCBw8PFgIeB1Zpc2libGVoZGQCCQ8WAh4Fc3R5bGUFDWRpc3BsYXk6bm9uZTtkZEjYzMWMovvrGmuSrQHwc5ZXgqXCrf+lekz1GgsdjUd+" name="__VIEWSTATE">
</div>
<div>
visiblelabel::
<span id="visiblelabel">visiblelabel</span>
<br>
labelwithvisiblefalseonaspx::
<br>
labelwithdisplaynoneonaspx::
<div style="display: none;">
<span id="labelwithdisplaynoneonaspx">labelwithdisplaynoneonaspx</span>
</div>
<br>
labelwithvisiblefalseonserverside::
<br>
labelwithdisplaynoneonserverside::
<div id="divforlabelwithdisplaynoneonserverside" style="display: none;">
<span id="labelwithdisplaynoneonserverside">labelwithdisplaynoneonserverside</span>
</div>
<br>
</div>
</form>
</body>
</html>
display>none
,否则它不会起作用。 - ismnoiet