Link to home
Start Free TrialLog in
Avatar of OTM
OTM

asked on

passing variables from a class in app_code without using 'return' - asp.net c#

Hi,

How can i pass a variable such as a string or a no. from the class file to a webform control or the webforms codebehind file?

Can i use a session variable?

i cant use:

return variablehere;

as its used for another purpose already.. I hope this makes sense.

Thanks,

Sam
Avatar of it_saige
it_saige
Flag of United States of America image

You could pass the variable as a method parameter by reference and set the variable inside the function.

http://msdn.microsoft.com/en-us/library/0f66670z(v=vs.71).aspx

-saige-
You could use a Session variable, but it is a bit of a messy solution. Your other options are either a "ref" variable, or an "out" variable:

    http://www.c-sharpcorner.com/UploadFile/mahesh/out_and_ref11112005002102AM/out_and_ref.aspx
SOLUTION
Avatar of ALaRiva
ALaRiva
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of OTM
OTM

ASKER

A "getter" was exactly what i needed, i just needed a good example to learn from and now i've implemented this into my project.

Thanks