how to copy the data in textboxes [Resolved]

Posted by Kishore22 under ASP.NET on 9/18/2013 | Points: 10 | Views : 2059 | Status : [Member] | Replies : 6
how to copy tha data from one text box to other

how to copy the data from one dropdown list to another dropdown llist




Responses

Posted by: Bandi on: 9/18/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Here's a simple way of copying Text From One ASP.NET Text Box to Another as the user types, using JavaScript
Add the following TextBox to your page
<asp:TextBox ID="txtOne" runat="server" onkeyup="OneTextToOther();"></asp:TextBox>

<asp:TextBox ID="txtTwo" runat="server"></asp:TextBox>


Now add the following JavaScript in the <head> section of your page

<head>
<title></title>
<script type="text/javascript">
function OneTextToOther() {
var first = document.getElementById('<%= txtOne.ClientID %>').value;
document.getElementById('<%= txtTwo.ClientID %>').value = first;
}
</script>
</head>


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kishore22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/18/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer these links for copying data from one drop down list to another
http://www.codeproject.com/Questions/578240/CascadingplusDropplusdownpluslistplusinplusasp-net
http://stackoverflow.com/questions/2667846/how-to-copy-items-from-one-dropdownlist-to-another

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kishore22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/18/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
check this code



protected void Bt_Submit_Click(object sender, EventArgs e)
{
Txt2.Text = Txt1.Text;
int ItemsCnt = DrpList.Items.Count;

for (int i = 0; i <= ItemsCnt-1; i++)
{
DropDownList1.Items.Add(DrpList.Items[i].Text);
}

}

<form id="form1" runat="server">
<asp:TextBox ID="Txt1" runat ="server" ></asp:TextBox>
<asp:DropDownList ID="DrpList" runat ="server" >
<asp:ListItem Text ="Asp.net" Value ="0">Asp.net</asp:ListItem>
<asp:ListItem Text ="Vb.net" Value ="1">Vb.net</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Bt_Submit" runat ="server" Text ="Copy Data"
onclick="Bt_Submit_Click" />
<asp:TextBox ID="Txt2" runat ="server" ></asp:TextBox>
<asp:DropDownList ID="DropDownList1" runat ="server">
</asp:DropDownList>
</form>

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Kishore22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/18/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Kishore,

1. How to copy tha data from one text box to other.
Here is you code:-

private void textBox1_Leave(object sender, EventArgs e)

{
textBox2.Text = textBox1.Text;
}

private void textBox2_Enter(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text;
}


2. How to copy the data from one dropdown list to another dropdown list?
Here is code:-

foreach (ListItem li in DrpList.Items)

{
DropDownList1.Items.Add(li);
}


Happy Coding

If it helps you or directs U towards the solution, MARK IT AS ANSWER

Kishore22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/18/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear kishor,

If your problem is solved, then Click on MARK IT AS ANSWER link.

Happy Coding
If it helps you or directs U towards the solution, MARK IT AS ANSWER

Kishore22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/18/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Copy data from one textbox to another
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TextBoxAndTextBox.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 OneTextToOther() {
var first = document.getElementById('<%= txtOne.ClientID %>').value;
document.getElementById('<%= txtTwo.ClientID %>').value = first;
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<%--copy data from one textbox to another--%>
<asp:TextBox ID="txtOne" runat="server" onkeyup="OneTextToOther();"></asp:TextBox>
<asp:TextBox ID="txtTwo" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kishore22, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response