September 16th, 2003, 12:48 PM
-
Communication between forms ?
First I want to appologize for all my questions. I never worked with vb.net and the info I have is on .6 and no one where I am can help me about it and I need to correct the errors (there is too many
).
Is it still possible to communicate forms together ?
I mean, I have a form where the user click a button and that create a new form. On this one the person add some information about a new user or something like that. But I need that information to get returned and saved in the first form.
is it still possible to do something like that ? You can't use frmForm1.Textbox1.text = frmForm2.TextBox2.text
soo is there a way I can return the information ?
Or I just simply save it in a property of the class Frame I am doing and then with the first form when it is closed I just do a Get Property and show it ?
something like frmform1.textbox1.text = frmform2.getInfo()
?
September 16th, 2003, 01:05 PM
-
Things like this (transfering data within several pages) are imho coded with help of the session object.
Assuming you have three pages. Page1.asp contains textboxes with textboxes regarding Firstname, Lastname and CompanyName, Second Page information about location, e.g. Street, StreetNo, ZipCode and City, and last page with all information.
You store on each page the values of your textbox in your Session object if the user clicks on "Next Page":
Code:
private void btnSubmit_Click(object sender, System.EventArgs e) {
Session["txtFirstname"] = txtFirstname.Text;
Session["txtLastname"] = txtLastname.Text;
Session["txtCompanyName"] = txtCompanyName.Text;
// Forward user to second page
Response.Redirect("Page2.aspx");
}
...and forward the user to your next page. On your last page you just re-read your values out of the session object:
Code:
<tr>
<td>Firstname</td>
<td><%=Session["txtFirstname"]%></td>
</tr>
<tr>
<td>Lastname</td>
<td><%=Session["txtLastname"]%></td>
</tr>
... and so on ...
September 16th, 2003, 01:47 PM
-
I know all that stuff. but I am not working with ASP or anything. I am working on Visual Basic .Net version.
Now what I am trying to do is to declare a new property for that frame.
Code:
Public strVille As String
but I can't set it.
Code:
Public Sub SetValues(ByVal strVilleParam As String)
Try
strVille = strVilleParam
I can make that work, I will be able to set it and then may be use a get option before I close the window.
I believe it would kinda be the only way for me to make it work.
September 16th, 2003, 02:02 PM
-
Oh, heh - sorry, i meant you did in ASP.Net within a VB Project :-).
That's pretty easier in VB (Windows Application) than in ASP, you just change your declations of your TextBoxes, ComboBoxes or whatever Control where your values are saved which you want to transfer from "private" to "public" so you can access it from outside your form.
Code:
// from
private System.Windows.Forms.TextBox textBox1;
// to
public System.Windows.Forms.TextBox textBox1;
In your parent form, do something like this:
Code:
private void btnOpenNewWindow_Click(object sender, System.EventArgs e) {
FNewWindow f = new FNewWindow();
// this will open your new window modal, ie. this call
// will be stuck till the user closes the window
f.ShowDialog();
// do something with the values of our form
string str1 = f.textBox1.Text;
string str2 = f.textBox2.Text;
string str3 = f.textBox3.Text;
// ...
}
(this is C#, but should be easily transfered to VB)
September 16th, 2003, 02:21 PM
-
damn it you have reason, it's even more easier like that !
I complicated my setting by creating a new variable that is public and that is changed via the textbox instead of just changing the textbox property ! damn it ! 
I will know for next time ! 
I didn't do what my signature is saying !
!
I am starting to know way better how vb.net work and I am getting away the vb.6 and starting to work has I was working java with the object oriented script ! and I loving more and more .net !
Last edited by Watever; September 16th, 2003 at 02:25 PM.