Hi AbushNasi,
The same can be done using jQuery.
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@Html.DropDownList("ddlGender", new List<SelectListItem>
{ new SelectListItem{Text="Male", Value="M"},
new SelectListItem{Text="Female", Value="F"},
new SelectListItem{Text="Other", Value="O"}}, "Please select")
@Html.CheckBox("chkOther", false, new { disabled = "disabled" })
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#ddlGender").change(function () {
if ($(this).val() == "O") {
$("#chkOther").removeAttr("disabled");
$("#chkOther").focus();
} else {
$("#chkOther").attr("disabled", "disabled");
}
});
});
</script>
</body>
</html>
Screenshot