2012-09-25 80 views
0

我無法隱藏單選按鈕上的文本。這裏是收音機的asp ...asp hide單選按鈕標籤

<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"; 
} 

爲什麼文本不被隱藏,以及如何使其不可見?

謝謝,戴夫K.

回答

2

一個簡單的辦法解決,這將是乾脆把整個事情的面板,然後隱藏。或者有沒有理由不能這樣做?

+0

謝謝你的想法。在asp中仍然很新,甚至沒有想到這一點。 –

+0

通常隱藏或顯示面板是一個好主意。除非你正在爲單個元素做,否則隱藏/顯示該元素是更好的選擇。 – Cruril

1

查看您的頁面上由ASP.NET生成的HTML。我想你會發現LABEL標籤是爲單選按鈕的文本發出的。你的Javascript不是針對LABEL的 - 你正在瞄準INPUT的。

另一個建議 - 切換類來顯示/隱藏它們。跟蹤更容易,並允許您使用CSS來鞏固其他樣式的優點。

+0

你對於作爲標籤的文字絕對正確。 @Chris建議將無線電放置在面板中。 –