asp hide radiobutton标签

时间:2012-09-25 20:18:29

标签: javascript asp.net css

我在单选按钮上隐藏文字时遇到问题。这是无线电的asp ......

<asp:RadioButton ID="rdViewPrint" Text="View/Print" runat="server" OnClick="javascript:disableFields();" GroupName="viewSend" Checked="True" style="margin-left:10px;" />
<asp:RadioButton ID="rdEmail" Text="Email" runat="server" OnClick="javascript:emailFields();" GroupName="viewSend" style="margin-left:10px;" />
<asp:RadioButton ID="rdFax" Text="Fax" runat="server" OnClick="javascript:faxFields();" GroupName="viewSend" style="margin-left:10px;" />

在页面加载时,javascript函数运行下面的函数。单选按钮的圆圈是隐藏的,但文本仍然存在。

function noVisit() {
     document.getElementById('<%=lblViewSend.ClientID%>').style.display = "none";
     document.getElementById('<%=rdViewPrint.ClientID%>').style.display = "none";
     document.getElementById('<%=rdEmail.ClientID%>').style.display = "none";
     document.getElementById('<%=rdFax.ClientID%>').style.display = "none";
     document.getElementById('<%=btnFull.ClientID%>').style.display = "none";
     document.getElementById('<%=btnSummary.ClientID%>').style.display = "none";
     document.getElementById('<%=btnPrivate.ClientID%>').style.display = "none";
}

为什么文本不会被隐藏,如何让它不可见?

谢谢,Dave K。

3 个答案:

答案 0 :(得分:2)

对此的一个简单的解决方法是将整个事物放在面板中然后隐藏它。或者有没有理由你不能这样做?

答案 1 :(得分:1)

查看页面上ASP.NET生成的HTML。我想你会发现LABEL标签是为单选按钮的文本发出的。您的Javascript不是针对LABEL的 - 您的目标是INPUT。

另一个建议 - 切换类以显示/隐藏它们。更容易跟踪并允许您使用CSS巩固其他样式优势。

答案 2 :(得分:0)

尝试此代码。

rdViewPrint.Visible = false;
rdEmail.Visible = false;
rdFax.Visible = false;