how to copy the text box value to another textbox [Resolved]

Posted by Kishore22 under ASP.NET on 9/18/2013 | Points: 10 | Views : 1404 | Status : [Member] | Replies : 4
i want to copy the data in first textbox to second text box

and at the same time

i want to copy the selected value in dropdownlist1 to the dropdownlist 2 please explain with a sourcee code




Responses

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

Up
0
Down

Resolved
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: Write2varun on: 9/18/2013 [Member] Starter | Points: 25

Up
0
Down
do you want to do it on button click event

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

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

Up
0
Down
<%@ 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: 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

Login to post response