473,473 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Code Behind & Variables!

Hi,

Can I use variables declared in a code behind file in a .aspx file?

If so, what needs to be done to make these variables available?

If I am using a .ascx file instead of an .aspx, does this have any impact?

Responses are appreciated.
Cheers,

Adam
Nov 19 '05 #1
3 1160
Yes. They need to be declared protected or public.

"Adam Knight" <de*@brightidea.com.au> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Hi,

Can I use variables declared in a code behind file in a .aspx file?

If so, what needs to be done to make these variables available?

If I am using a .ascx file instead of an .aspx, does this have any impact?

Responses are appreciated.
Cheers,

Adam

Nov 19 '05 #2
Since codebehind is simply a base class to the ASPX or ASCX, as long as members
are marked protected they are visible to the derived class.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

Can I use variables declared in a code behind file in a .aspx file?

If so, what needs to be done to make these variables available?

If I am using a .ascx file instead of an .aspx, does this have any
impact?

Responses are appreciated.

Cheers,

Adam


Nov 19 '05 #3
As Marina and Brock have answered, yes you can...it's merely an
accessibility issue. The point of my reply is to ask why you want to?
There are certainly cases where you have to, but as a general rule I'd say
it's good to avoid this if possible.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Adam Knight" <de*@brightidea.com.au> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Hi,

Can I use variables declared in a code behind file in a .aspx file?

If so, what needs to be done to make these variables available?

If I am using a .ascx file instead of an .aspx, does this have any impact?

Responses are appreciated.
Cheers,

Adam

Nov 19 '05 #4

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

Similar topics

5
by: Dan | last post by:
We have a simple site. It's a frameset with two frames a left and a right. The left frame is essentially a list of records from a database (using a server-side repeater control). When you click...
8
by: Brett Robichaud | last post by:
I understand how code-behind can handle events for a page, but can I call a code-behind method from within a <script> tag in my ASP.Net page, or can I only call methods defined in other <script>...
0
by: Glenn Engelbart | last post by:
I am trying to find out a way to get more code re-use & object orientation in the UI portion of my apps. (There already is plenty of both in the DataAccess & Business Logic portion of my apps. ...
7
by: Marco | last post by:
Is it possible to access an variables' value, using javascript The variable is created on the code behind What i want to know is if i give a value to an variable created in the code behind, is it...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
7
by: Rich Grise | last post by:
OK, I don't know if this is Off-Topic for the group(s), because "QT" isn't "Pure C++", and Slackware is a distro, but those guys are sharp. :-) And I've crossposted to sci.electroncs.design because...
3
by: Yourself | last post by:
Hi, I'm trying to post data to PayPal for a shopping cart, basically I want to replicate a form like the following, but create the variables dynamically from code behind: <form...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
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
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.