Java Script: Enable/Disable Server controls based on
DropDownValue.
Client side and Sever side also word if changes in both the places
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//Attach change event hanlder to dropdownlist
$("#<%=DropDown1.ClientID%>").change(function () {
//check if selected value is not equal to
if ($(this).val() == 'Yes') {
//Hide the button
$("#<%=tblName.ClientID%>").hide();
$("#<%=tbPhone.ClientID%>").hide();
}
if ($(this).val() == 'No')
{
//show the button
$("#<%=tblName.ClientID%>").show();
$("#<%=tbPhone.ClientID%>").show();
}
});
if ($('#<%=DropDown1.ClientID %> OPTION:selected').val() == 'Yes') {
$("#<%=tblName.ClientID%>").hide();
$("#<%=tbPhone.ClientID%>").hide();
}
else {
$("#<%=tblName.ClientID%>").show();
$("#<%=tbPhone.ClientID%>").show();
}
});
</script>
No comments:
Post a Comment