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

Write a function which accepts a sentence as input parameter.Each word in that sentence is to be reversed. Space should be there between each words.Return the sentence with reversed words to main function and produce the required output. for eg:- i/p: jack jill jung kill o/p: kcaj llij gnuj llik

1 Answers   Mind Tree,


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

1 Answers  


program for straight line(y=mx+c)

0 Answers   Mind Tree,


Coding for Manipulate XML File Data Using C#?

1 Answers  


program to reverse the order of words in a string.

2 Answers   Mind Tree,






"c sharp" code for factorial using static variables

9 Answers  


program to reverse the order of digits in a given number of any length.

1 Answers   Mind Tree,


Coding for using Nullable Types in C#?

1 Answers  


How to find No of classes,Packages,No of Methods per Classes and Depth of Inheritance for selecting source code in windows form application using c# .net? (Source code is input Program. It may be Java or .net) Please help me..) Thanks..)

0 Answers  


Write a program to input an integer and - display the reverse - display the sum of each digit - should include logic that considers the input number as any number of digits long

2 Answers   Mind Tree,


Give the code for Handling Mouse Events?

0 Answers  


Can you declare an array of mixed Types?

1 Answers   HCL,


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)