Home > Archive > C# > September 2005 > Passing variables between classes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Passing variables between classes
|
|
| sabarad_arun@hotmail.com 2005-09-01, 6:58 pm |
| Hi All,
Please help me on this...
I have a form1 with some controls.When i select editcontrol on form1 it
opens up form2.I have some settings(variables) in form2.I make some
changes to the settings in form2.When i click on ok on the Form2,i
should be able to access the changed values from form1.I want to have
this without creating an object of form2 in form1.
Can anybody suggest me on this.
Thanks
Arun
| |
| Robert Megee 2005-09-02, 7:59 am |
| On 1 Sep 2005 06:10:51 -0700, sabarad_arun@hotmail.com wrote:
>Hi All,
>
>
>Please help me on this...
>
>
>I have a form1 with some controls.When i select editcontrol on form1 it
>
>opens up form2.I have some settings(variables) in form2.I make some
>changes to the settings in form2.When i click on ok on the Form2,i
>should be able to access the changed values from form1.I want to have
>this without creating an object of form2 in form1.
>
>
>Can anybody suggest me on this.
>Thanks
>Arun
if the forms are in the same session you can put the variables into
session state variables.
Session["var1"] = davar ; // to set the variable.
davar = (type) Session["var1"] ; // to read the variable.
If they are different sessions you can put them in
the command that calls the other form. You will need
to pass them as strings.
response.redirect("form1?var1=daval");
and you read the variable like this:
davar = Request.QueryString["var1"];
See if you can use these.
Robert
| |
| Code Heaven 2005-09-19, 6:01 pm |
| quote: Originally posted by sabarad_arun@hotmail.com
Hi All,
Please help me on this...
I have a form1 with some controls.When i select editcontrol on form1 it
opens up form2.I have some settings(variables) in form2.I make some
changes to the settings in form2.When i click on ok on the Form2,i
should be able to access the changed values from form1.I want to have
this without creating an object of form2 in form1.
Can anybody suggest me on this.
Thanks
Arun
Hello,
I think you are not talking about a web application , so The only way to see the varaibles of a class in another one without making an object is using static key word, so you can access that variable from the class name:
Example:
class One
{
public static string variable;
}
class Two
{
void main()
{
MessageBox.Show(One.variable);
}
}
Regards |
|
|
|
|