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,


"c sharp" code for factorial using static variables

9 Answers  


c# coding for a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors not using the Big-integer and Exponential Function's.

1 Answers   TCS,


working with arrays

1 Answers  


how to change password in .net with c # with ado.net and also SQL server 2008 change password

1 Answers  






Write a program to count 3Letter, 4Letter and 5Letter words from a file and print the number of 3Letter, 4Letter and 5Letter words. Delimiter is space, tab, hifen. Also we should not consider the line in the file after we encounter # in that line.

0 Answers   Mind Tree,


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,


c# code to Count number of 1's in a given range of integer (0 to n)

0 Answers  


Hello I am hosting remoting within IIS. Everything works just fine as long as I allow anonymous access at the IIS level. When I allow only Windows Authenticated sessions, something very strange happens: If the client activates the remote object with IP address - works fine If the client activates it using a machine name - get http 401 exception is thrown. The exception is thrown when the client calls the remote method. I set the channel's useDefaultCredentials property to true. Any idea how to allow Windows Authentication? Here is the call stack: System.Net.WebException: The remote server returned an error: (401) Unauthorized .. ---> System.ComponentModel.Win32Exception: The target principal name is incorrect at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean handshakeComplete) at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob, Boolean handshakeComplete) at System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest webRequest, ICredentials credentials, Boolean preAuthenticate) at System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest webRequest, ICredentials credentials, Boolean preAuthenticate) at System.Net.NegotiateClient.Authenticate(String challenge, WebRequest webRequest, ICredentials credentials) at System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest request, ICredentials credentials) at System.Net.AuthenticationState.AttemptAuthenticate (HttpWebRequest httpWebRequest, ICredentials authInfo) --- End of inner exception stack trace ---

0 Answers   Infosys,


Coding for using Nullable Types in C#?

1 Answers  


Write a program which has a function and that function should take 2 or 3 or any number of strings and it should return the largest common prefix of all those strings. If there is no common prefix it should return an empty string. for eg:- INPUT OUTPUT glo {glory,glorious,glod} gl {glad,glow} {calendar,phone} empty string

2 Answers   Mind Tree,


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  


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)