Hide Asp Radio Button Text
I have a asp radio button and i want to set it's visibility to false in javascript. I am t
Solution 1:
It's because:
<asp:RadioButtonID="rad1"Text="my radio button"runat="server"GroupName="b" />
Is actually rendered to (you can view the source):
<input name="b"id="rad1"type="radio" value="rad1">
<label for="rad1">my radio button</label>
So if you want to make both hidden you have to do something like:
var rad1 = document.getElementById("rad1");
rad1.style.visibility = "hidden";
rad1.nextSibling.style.visibility = "hidden";
or an easier approach would be to place the radio button in a div
for example, something like:
<divid="foo"><asp:RadioButtonID="rad1"Text="my radio button"runat="server"GroupName="b" /></div>
and then just do:
document.getElementById("foo").style.visibility = "hidden";
Solution 2:
Try this by JQuery First don't forget to add Jquery CDN at your page Header.
<headrunat="server"><title></title><scriptsrc="https://code.jquery.com/jquery-1.11.1.min.js"></script></head>
And the functions will be. rdName => is your RadioButton Id
$('#rdName').css('display','none'); //Hide Radiobutton.
$('label[For= "rdName"]').css('display','none'); //Hide Radiobutton Text.
And You have another solution to drag the radiobutton in a and give it an Id. then Hide / Show it, then the radiobutton will aslo be hidden and its text.
Solution 3:
you should use this type of code to get asp.net controls
document.getElementById('<%=rad1.ClientID %>').style.visibility = "hidden";
by this you can set visibility to false .
Solution 4:
You can use jquery for hiding it,
$('#rad1').parent().hide();
let me know if it works or not. It should work fine
Post a Comment for "Hide Asp Radio Button Text"