Issue in setting radio button as readonly.

Posted by NamrataC under JavaScript on 10/20/2009 | Views : 6661 | Status : [Member] | Replies : 3
Hi,
I'm using two asp.net radio buttons in my page. At some instance I want to make these radio buttons readonly using javascript. Please help me for the same.

Thanking you all in anticipation.




Responses

Posted by: Vuyiswamb on: 10/21/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day

What you need to do is to Disable and Enable the Radio button. here is how its done in Javascript

http://www.codetoad.com/javascript/enable_disable_form_element.asp


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

NamrataC, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Poster on: 10/21/2009 [Member] Starter

Up
0
Down
Probably following links will help you.

http://forums.asp.net/p/1226039/2200267.aspx

http://codingforums.com/showthread.php?t=87752

Thank you.

NamrataC, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SurajRane on: 11/3/2009 [Member] Starter

Up
0
Down

you can do it using following code.



 

<script>
function EnableDisableRadio(flag)
{

document.getElementById("<%=RadioButton1.ClientID%
>").disabled = flag;

return false;
}
</script>

<form id="form1" runat="server">

<asp:RadioButton ID="RadioButton1" runat="server" Text="Radio" />


<asp:Button ID="btnEnable" runat="server" Text="Enable"

OnClientClick="return EnableDisableRadio(false);" />

<asp:Button ID="btnDisable" runat="server" Text="Disable"

OnClientClick="return EnableDisableRadio(true);"

</form>


No need to use ClientID if your page/control is not having any master page.you can directly pass controls ID.



NamrataC, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response