473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to get the variable from page_load

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!!
Nov 13 '05 #1
2 6143
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
Nov 13 '05 #2
"lsf_80" <li***@ytlesolutions.com> wrote in message news:<OE**************@TK2MSFTNGP10.phx.gbl>...
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.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joseph Luner | last post by:
I am having problem postback, (code shown below) the variable "my_str" is lost after clicking the "submit" button. Isn't it suppose to display "changed" after posting back? Is there anyway I...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
1
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
0
by: Steve Wark | last post by:
If I create two aspx pages, place three text boxes (working with VS .net 2003 and web form controls) and a button on both forms. On the first page, the button is set to use the "onClick" to open...
9
by: Shapper | last post by:
Hello, I am declaring a variable in my aspx.vb code as follows: Public Class catalogue Public productid As String Private Sub Page_Load ... I have an image button where I call the...
10
by: Mark A. Sam | last post by:
Hello, I am using Visual Web Developer and decared a Public Variable in the Class section. I assigned a value in the load section, and on a button I set it up to increment, but it always...
6
by: Neo Geshel | last post by:
I am trying to deal with an image in code-behind. I consistently get the following error: Server Error in '/' Application. Object variable or With block variable not set. Description: An...
2
by: Jay | last post by:
Is it possible to use the <% %> tag to embed a variable from page_load into a meta tag in the aspx source? Somehow I am not getting the value out of my variable properly - probably not using...
4
by: Arpan | last post by:
The following code works fine: <script runat="server"> Dim strName As String = "Arpan" Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) Page.DataBind() End Sub </script> <form...
10
by: Phillip Vong | last post by:
Newbie learning in VB.NET 2. I'm creating a simple ASP.NET 2 page and I pulling a querystring from a link and I want to use this querystring over and over again through out the page. Example....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.