How can I back to the previous form without loosing the data of the previous form.
Printable View
How can I back to the previous form without loosing the data of the previous form.
Wow, that's a lot of detail. We don't know anything about how your app is structured so we couldn't really advise without guessing. I suggest that you read the Forms in VB.NET tutorial in my signature. The principles are exactly the same for C# and there are links to code converters in my signature to convert the example code.
Sohel,
Put the data of previous form into Session. And retrive those when you came back to that form again....
For example:
Session["data1"] = abc;
Again
text1.text = Session["data1"];
Best of Lucks....
Rajib
Do you want to revert back to the data of the form or the form itself? If its the data you could use some kind of session. If its the form itself, then simply hide the form and when you want to revert back to it, you could re-show the previous form.
Eh? Is this a desktop app, or a web app? :confused:
If it's a web application, you should post in the ASP.NET forum.
It's a desktop application.
You really are a man of few words, aren't you. See how everyone is guessing at what the situation might be? That's because you haven't given enough information. Tell us what you are trying to achieve. "Back to the previous form" could mean a number of different things. We don't know anything about your app so don't assume that we will assume the same things as you. Describe your situation and you'll get more accurate advice. Help us to help you.Quote:
Originally Posted by zisohel
Also, have you read that tutorial? I'm quite sure that it will explain what you need to know, plus give you other importatnt information so you won't need to ask many potential questions in the future.
Suppose I have two forms form1 and form2. In form1 user have to put the user id and password. If it is valid then the form2 will appear and form1 should not be visible. After doing the operation at form2 I want to back to the form1 and the user id should be visible in the textbox.
That's better :)
Hide the first form and use ShowDialog() to show the second form, that will wait for it to be dismissed. Then just show self again.
Obviously, you would give things slightly better names than that.Code:this.Visible = false;
Form2 theOtherWhatnot = new Form2();
theOtherWhatnot.ShowDialog();
this.Visible = true;
Thanks for your answer. I really want to do that.
You'll also need to declare a public property in Form2 to return the user ID. You can then retrieve the value of that property once the dialogue has been dismissed.Code:this.Visible = false;
Form2 theOtherWhatnot = new Form2();
if (theOtherWhatnot.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Get the user ID from the dialogue. You must defaine the UserID property yourself.
this.TextBox1.Text = theOtherWhatnot.UserID;
}
// You should destroy the dialogue form.
theOtherWhatnot.Dispose()
this.Visible = true;
Isn't the user id being inputted in the current form?
Quite correct it seems. I didn't read that last properly. I did ask for it after all. I shouldn't have to read it too. ;) :blush: I assumed that there was some desire to pass data between the forms but it would appear not.Quote:
Originally Posted by penagate