how to get the variable from page_load

  • Thread starter Thread starter lsf_80
  • Start date Start date
L

lsf_80

I am using ASP.net and C# as code behind.

I wrote one function in the "page load" (code behind) and how can i call
back the variable in the aspx page?

Thank you.

if i put response.write, error message prompted: "WebService1.WebForm10.aa'
is inaccessible due to its protection level"

So, how to solve it?

Thank you very much!!
 
Hi.
I wrote one function in the "page load" (code behind) and how can i call
back the variable in the aspx page?

You wrote a function in the "page load"? then you speak about a variable --
what do you mean exactly?

If you want to store a variable for s session use the "Session"-object,
like:

String myVariableWhichIWantToUseInTheSession = "abc";
Session["SomeIdentifier"] = myVariableWhichIWantToUseInTheSession;
....
and to use it:
String myVariable = (String) Session["SomeIdentifier"];

// don't forget exception handling

I hope this helps you - your posting was not very clear.

--> Please use your real name.


hth,
Chris
 
lsf_80 said:
I am using ASP.net and C# as code behind.

I wrote one function in the "page load" (code behind) and how can i call
back the variable in the aspx page?

Thank you.

if i put response.write, error message prompted: "WebService1.WebForm10.aa'
is inaccessible due to its protection level"

So, how to solve it?

Thank you very much!!

I'm guessing that you declared the variable in the code behind as a
private variable. Private variables will not be available to the page,
since the page is not an instance of the code-behind class, but an
instance of a class derived from the code-behind class. If you declare
the variable as public or protected, it should work fine.
 
Back
Top