Hi,
Lets assume that u have created two text-boxes and a check-box in ASP.net as given below:
<asp:TextBox ID="textBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="textBox2" runat="server"></asp:TextBox>
<asp:CheckBox ID="checkbox1" runat="server" onclick="copyValue(this)" />
You can write a javascript function to copy value from one textbox into the other textbox, and call the same function on “onclick” event of the checkbox. Same function can be used to clear the textbox on unchecking the checkbox. Code is given below.
<script type="text/javascript">
function copyValue(Chk) {
if (Chk.checked) {
var textVal = document.getElementById('<%=textBox1.ClientID%>').value;
document.getElementById('<%=textBox2.ClientID%>').value = textVal;
}
else {
document.getElementById('<%=textBox2.ClientID%>').value = "";
}
}
</script>
Hope this will help.