C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

to move a value from one form to another form..


Posted Date: 07 Jan 2009      Posted By: gopal      Member Level: Gold     Points: 1   Responses: 5



hi friends..

in windows application with c# ..i want to move one textbox value to another form textbox..

for example in form1, textbox.text=100 then i want to move this value to form2 textbox using c#..

using vb i done this .. but i want to do this in c#...

its in windows apllication using c#..

its urgent..

thanx
gopal.s





Responses

Author: divya    07 Jan 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

Hi,
U can do it storing the value in textbox to a session variable,or u can pass the value through querystring when redirecting to other page.
Session variable
In the form 1 u can store that in session variable as follows
session["text"]=textbox1.text.tostring();

Query string

response.redirect(form2.aspx?ID=" + textbox1.text.tostring() + ")
Then u can take this value from the page load or in any event as follows
string str=request("id");



Author: Syed Shakeer Hussain     07 Jan 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 4

Hi..
gopal

Hi..first page value in second page

create one New class as A
Class A
{

//int that decalare a varialbe as username

pubilic static string username="vaibhav";


}

which page you want username you can use it.

Class B
{
//suppsoe you want to display username in a txtbox1

textusername.Text=A.username;

}


//Static variable can be accessed with the class Name itself..

so..without using Session,Cookies..you can pass value to another page by using static variable


Thanks & Regards!
Syed Shakeer Hussain



Author: Abhi    07 Jan 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

hi,
go to form1.designer.cs
make your textbox as public

then
goto form2

create object of form1 class

form1 objfrm = new form1

string str = objfrm.textbox1.text



Author: sridhar    07 Jan 2009Member Level: BronzeRating: 2 out of 52 out of 5     Points: 3

gopal u can use properties concept or overloaded constructor

write overload constructor in form 2

ex: Form2(string val)
{
textbox1.text=val;
}

in form1 button click

create the form2 object

Form2 f2=new form2(textbox.text);
form1.hide;
form2.show()

and one more thing as per my knowledge there is no session and query string concept in windows application



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Why we came across to .NET rather than C,C++Java.......plzzzzzz help me.........
Previous : Very urgetn using c# how to search the database recodrs alphabetical wise
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use