html select control is not disabled at html radio button selected

Posted by Sunitajadhav under ASP.NET on 12/14/2009 | Views : 3161 | Status : [Member] | Replies : 3
Hello friends,
I am giving some code here.I want to disabled the select control items when i am selecting radio button.


<input type="radio" id="RBRenewableResource" runat="server" value="R" name="RCGroup" checked="True" onserverchange="RBRenewableResource_ServerChange"/>Renewable
<input type="radio" id="RBNonRenewableResource" runat="server" value="NR" name="RCGroup" onserverchange="RBNonRenewableResource_ServerChange"/>Non Renewable
<select id="DDListRenewableResource" runat="server" style="width: 226px">
<option>Skilled Workers</option>
<option>Casual Labours</option>
<option>Machines</option></select>
<select id="DDListNonRenewableResource" runat="server" style="width: 226px"><option>Materials</option></select>


I have written some code.Its not working.

protected void RBRenewableResource_ServerChange(object sender, EventArgs e)
{
if (RBRenewableResource.Checked)
{
DDListRenewableResource.Disabled = true;
DDListNonRenewableResource.Disabled = false;
}
}

protected void RBNonRenewableResource_ServerChange(object sender, EventArgs e)
{
if (RBNonRenewableResource.Checked)
{
DDListNonRenewableResource.Disabled = true;
DDListRenewableResource.Disabled = false;
}
}


Thanks




Responses

Posted by: Vuyiswamb on: 12/14/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
set the Autopostback property to true on both your Controls.

Thank you for posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

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

Posted by: Chikul on: 12/14/2009 [Member] Bronze

Up
0
Down
Hi,

you can use Javascript for the same.

 

<head>
<script language="javascript" type="text/javascript">
function rdbChange()
{
if (document.getElementById('RBNonRenewableResource').checked)
{
document.getElementById('divselect').style.display="none";
}
else
{
document.getElementById('divselect').style.display="block";
}

}
</script>
</head>
<body>
<form>
<input type="radio" id="RBRenewableResource" runat="server" value="R" name="RCGroup" checked="True" onclick="rdbChange()"/>Renewable
<input type="radio" id="RBNonRenewableResource" runat="server" value="NR" name="RCGroup" onclick="rdbChange()"/>Non Renewable
<div id="divselect" >
<select id="DDListRenewableResource" runat="server" style="width: 226px">
<option>Skilled Workers</option>
<option>Casual Labours</option>
<option>Machines</option></select>
<select id="DDListNonRenewableResource" runat="server" style="width: 226px"><option>Materials</option></select>
</div>

</form>
</body>


Regards,
Chikul

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

Posted by: Joshuab on: 12/23/2009 [Member] Starter

Up
0
Down
hi..
instead of

if (RBRenewableResource.Checked)


write it as

if (RBRenewableResource.Checked==true)



http://www.prodigyapex.com/

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

Login to post response