Copy Content of One Control to Another

Self-Innovator
Posted by Self-Innovator under jQuery category on | Points: 40 | Views : 1692
Using jQuery Copy the value from one Server Control to another


.aspx Design Page
<table align="center">
<tr>
<td>
<asp:Label ID="lblName1" Text="Enter the Name" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblCopyname" runat="server" Text="CopiedName"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtName2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnCopy" runat="server" OnClientClick="javascript:CopyName();return false;" Text="Copy" />
</td>
</tr>
</table>


jQuery Script Code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
function CopyName()
{
var name=$("#<%=txtName1.ClientID%>").val();
$("#<%=txtName2.ClientID %>").val(name);
return false;
}
</script>

Comments or Responses

Login to post response