473,322 Members | 1,714 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,322 software developers and data experts.

Public variable not seen by all controls on a Page

Hi all,

In ASP.NET 2.0 I have some pages that are composed of a Master Page and
several User controls. In one of the pages I declare a Public variable
within the code-behind of a User Control on the page.

I populate the variable during the Page_Load event of the User Control.

When I reference the variable in another part of the page, specifically in
Page_Load of the main ASPX or even Page_PreRender VS tells me the variable
is not declared.

Is there a place in the page where I can declare a variable (maybe using
something other than Public for the declaration?) so that it can be seen and
referenced by all members of the page, but Only within the page itself?

Thanks...
Dec 12 '07 #1
1 1454
You don't specify in your post how and with what code you are declaring this
variable. If your field is a public field in the UserControl or a public
property, then from anywhere in the Page you should be able to use
FindControl method to get a reference to your UserControl and access the
property and its value.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"John Kotuby" wrote:
Hi all,

In ASP.NET 2.0 I have some pages that are composed of a Master Page and
several User controls. In one of the pages I declare a Public variable
within the code-behind of a User Control on the page.

I populate the variable during the Page_Load event of the User Control.

When I reference the variable in another part of the page, specifically in
Page_Load of the main ASPX or even Page_PreRender VS tells me the variable
is not declared.

Is there a place in the page where I can declare a variable (maybe using
something other than Public for the declaration?) so that it can be seen and
referenced by all members of the page, but Only within the page itself?

Thanks...
Dec 12 '07 #2

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

Similar topics

2
by: Sky Sigal | last post by:
Hello: I'm currently messing around, and need as much feedback/help as I can get, trying to find the most economical/graceful way to build usercontrols that rely on styling to look any good... ...
4
by: Darrel | last post by:
I'm really stuck on the concept of using public variables to pass information between usercontrols. I'm pretty sure I'm just flubbing up the syntax. This is what I want: page usercontrol 1 -...
8
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
6
by: darrel | last post by:
I'm still not quite sure how best to handle the passing of data between controls. This is a method I'm using at the moment: I have an XML file that contains a variety of page-centric...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
8
by: Floris van Haaster | last post by:
Hi All! I have a question, i have a web application and I store some member information in a variable i declared in a module like: Public some_info_variable as string in module1.vb But...
4
by: Bugs | last post by:
Hi, I wonder if anyone can help me out. I'm building a vb.net application that has a form with a panel that contains several other sub forms (as a collection of controls). What I'm wanting to...
2
by: Web Search Store | last post by:
I am trying to make variables available in my web application by making user controls I classic asp I was able to put them all in an #include which made them available throughout the asp script...
11
by: Web Search Store | last post by:
Hello, I set up a web page with 2 user controls. In classic asp, the first one did all the declarations, and the second one used the values, and could reset it. In ASP.Net so far I can't...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.