textbox.Enabled = checkBox.Checked;
Mark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gif
<script type="text/javascript" language="javascript"> function enableTextBox() { var textBoxID = "<%= txtAddress.ClientID %>"; if (document.getElementById("<%= chkAssociation.ClientID %>").checked == true) document.getElementById(textBoxID).disabled = false; else document.getElementById(textBoxID).disabled = true; } </script> and than the control: <asp:CheckBox Checked="false" OnChange="javascript:enableTextBox();" ID="chkAssociation" runat="server" /> <asp:TextBox ID="txtAddress" Enabled="false" Text="Test" runat="server" />
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TextBoxAndCheckBox.aspx.cs" Inherits="CopyDataFromOneControlToAnother.TextBoxAndDropDownList" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" language="javascript"> function enableTextBox() { var textBoxID = "<%= txtAddress.ClientID %>"; if (document.getElementById("<%= chkAssociation.ClientID %>").checked == true) document.getElementById(textBoxID).disabled = false; else document.getElementById(textBoxID).disabled = true; } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:CheckBox Checked="false" OnChange="javascript:enableTextBox();" ID="chkAssociation" runat="server" /> <asp:TextBox ID="txtAddress" Enabled="false" Text="Test" runat="server" /> </div> </form> </body> </html>
Login to post response