how to copy the data in textboxes [Resolved]

Posted by Kishore22 under ASP.NET on 9/18/2013 | Points: 10 | Views : 1346 | Status : [Member] | Replies : 7
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: Satyapriyanayak on: 9/18/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="Insert_data_confirmation.WebForm3" %>


<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>

<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</div>
</form>
</body>
</html>


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Insert_data_confirmation
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
TextBox2.Text = TextBox1.Text;
DropDownList2.Items.Add(DropDownList1.SelectedValue);
}

protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Items.Add("select");
if (!IsPostBack)
{
DropDownList1.Items.Add("a");
DropDownList1.Items.Add("b");
DropDownList1.Items.Add("c");
}

}
}
}


If this post helps you mark it as answer
Thanks

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
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

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