Monday, May 25, 2009

Enable/Disable Link Button in Java script on Checked Changed Event

<asp:CheckBox ID="chkPermission" runat="server"
Text="I have permission / rights to upload these files and use it in public."
AutoPostBack="false" OnClick="JavaScript:EnableDisableSaveFile();" />


<asp:LinkButton ID="lbtnSaveFiles" runat="server"
Text="Save Files" OnClick="lbtnSaveFiles_Click"
Enabled="true"></asp:LinkButton>


<script type="text/javascript">

function EnableDisableSaveFile()
{

var checked=document.getElementById('<%= chkPermission.ClientID %>').checked;
document.getElementById('<%= lbtnSaveFiles.ClientID %>').disabled = !checked;
document.getElementById('<%= lbtnSaveFiles.ClientID %>').onclick =
function() { return checked };

}

</script>