473,398 Members | 2,389 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,398 software developers and data experts.

Can you use constants in .aspx files?

In InterDev, I frequently defined constants for my data-table field names,
then used #include statements to refer to the file(s) with those
declarations and substituted the constant declaration in any place where I
needed to refer to the field name. Is there any way to do the same sort of
thing in the <%# Container.DataItem (<field name>) %> references inside
..aspx files, for example, when creating DataLists (i.e. use a string
constant instead of a hard-coded string)?

Bob Rosen
Jul 19 '05 #1
1 2843
Why not just add them to the application object, or put them in web.config
and read them in from there. Or you can code your global.asax as a class
and use shared (static) values accesible from anywhere in your web app..

<%@ Application Classname="MyGlobals" %>
<script language="VB" runat="server">

public shared UserCount as integer = 1

Sub Application_OnStart()
End Sub

Sub Session_OnStart()
End Sub

Sub Session_OnEnd()
End Sub

Sub Application_OnEnd()
End Sub
</script>
--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Bob Rosen" <bo******@zipcon.net> wrote in message
news:10**************@news.zipcon.net...
In InterDev, I frequently defined constants for my data-table field names,
then used #include statements to refer to the file(s) with those
declarations and substituted the constant declaration in any place where I
needed to refer to the field name. Is there any way to do the same sort of thing in the <%# Container.DataItem (<field name>) %> references inside
.aspx files, for example, when creating DataLists (i.e. use a string
constant instead of a hard-coded string)?

Bob Rosen

Jul 19 '05 #2

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

Similar topics

20
by: 2obvious | last post by:
I've been trying to create read-only global variables by creating constants (Const) in my global.asa, but I can't seem to reference them. Sticking them in an include works fine, but it seems more...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
5
by: .NET beginner | last post by:
Hi all I need to create some strings, constants etc. in my class library that need to be shared across all the classes in my class library. How do I accomplish this? Do these strings and...
4
by: gabriel | last post by:
Greetings, I am working on a project and cannot choose the best way to achieve this : I got a method which returns an error code like this : DISK_FULL or PERMISSION_DENIED. Those are...
4
by: Jarod_24 | last post by:
I've managed find out how to start using the Win32 API's But some of these methods got constants that you should use when caling them. for example the LockSetForegroundWindow got a unsigned...
2
by: Bob Rosen | last post by:
In InterDev, I frequently defined constants for my data-table field names, then used #include statements to refer to the file(s) with those declarations and substituted the constant declaration in...
8
by: Steve | last post by:
Running asp.net 2.0 I have never used global constants and I am a bit confused on the subject. I want to give the admin of an application a lot of control over display. i.e. custom error...
12
by: Teresa Church | last post by:
Is there such a thing as defining a constant (or a variable) for a theme? For example, storing a color code and then using it in 4 or 5 places, so to change the color I only have to edit one line?...
54
by: shuisheng | last post by:
Dear All, I am always confused in using constants in multiple files. For global constants, I got some clues from http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx So in header...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.