how do i copy textbox contents of 1 form to another form

Answers were Sorted based on User's Feedback



how do i copy textbox contents of 1 form to another form..

Answer / umedh singh

Hi
Windows Application Coding
##Form1##
on button_click event
Form2 f2 =new Form2();
f2.form1inform2=this;
f2.show();

##Form2##
public form1 form1inform2;//variable
on form2_load event
this.TextBox1.text=((form1)this.form1inform2).textbox1.text;
.........................................
Web Application coding use QueryString
on button_click event
Response.Redirect("Default2.aspx?a="+textBox1.text);

on page_load event
textBox1.text=Request.QueryString["a"].toString();

Is This Answer Correct ?    5 Yes 2 No

how do i copy textbox contents of 1 form to another form..

Answer / sreeni

both the above answers are correct. Use First Answer for
Web applications and Second one for Windows applications.

Is This Answer Correct ?    7 Yes 5 No

how do i copy textbox contents of 1 form to another form..

Answer / justin dhas

Hi,
By using state management variables you can get the value of textbox from one form to another,like querystring,session,cookies etc
eg)
Session["value"]=textboxid.Text;//Set the value in one form
string s=Session["value".ToString()//get the value in another form

Is This Answer Correct ?    12 Yes 14 No

how do i copy textbox contents of 1 form to another form..

Answer / vishal m.s.

In 2nd form create an object for the 1st form
And write a code as below
//Object creation for form1 in form2(on command Button)

Form1 f1 = new Form1();
TextBox1.Text = f1.TextBox1.Text;

Is This Answer Correct ?    4 Yes 29 No

Post New Answer

More C Sharp Code Interview Questions

How to Create a Treeview Menu in ASP.NET with C#?

1 Answers  


How to add a value from textBox over an existing certain column in SQL Server

0 Answers  


How to use ASP.NET 2.0's TreeView to Display Hierarchical Data?

1 Answers  


Create a class called Accounts which has data members like ACCOUNT no, Customer name, Account type, Transaction type (d/w), amount, balance D->Deposit W->Withdrawal If transaction type is deposit call the credit(int amount) and update balance in this method. If transaction type is withdraw call debit(int amt) and update balance. Pass the other information like Account no,name,Account Type through constructor. Call the show data method to display the values.

1 Answers   Cognizant,


Hello Sir, Thanks for the Solution but, can you pls. Explain the coding for the Static Function & static variable from the below coding....waiting for Ans. class fact { public static void Main() { fact f=new fact(); int x=1; //Declaration of x as 1 int k=Convert.ToInt32(Console.ReadLine()); for(int i=1;i<=k;i++) { x= x *i; } System.Console.WriteLine(x); } }

0 Answers  






program to reverse the order of words in a string.

2 Answers   Mind Tree,


Using C# Write a program that performs the following. The user inputs a number and then enters a series of numbers from 1 to that number. Your program should determine which number (or numbers) is missing or duplicated in the series, if any. For example, if the user entered 5 as the initial number and then entered the following sequences, the results should be as shown. Input Sequence Output ---------------------- --------------- 1 2 3 4 5 Nothing bad However, if 7 were the high number, the user would see the results on the right for the following number entries: Input Sequence Output ---------------------- --------------- 1 3 2 4 5 Missing 6 Missing 7 And if 10 were the high number and the user entered the numbers shown on the left, note the list of missing and duplicate numbers: Input Sequence Output ---------------------- --------------- 1 2 4 7 4 4 5 10 8 2 6 Duplicate 2 ( 2 times) Missing 3 Duplicate 4 ( 3 times ) Missing 9 The program should check the high number that the user inputs to ensure that it does not exceed the size of any array you might be using for storage.

0 Answers  


how to get the table names via c sharp and column names also?

2 Answers   Sify,


How to export 2 datatables of a single dataset to 2 different worksheets of a single MSExcel file ?

0 Answers   Eastcom Systems,


Code for IP Address Comparison and Conversion in C#?

0 Answers  


IS Array list is generic or non generic

1 Answers  


Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C#

1 Answers  


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)