Can you use constants in .aspx files?

B

Bob Rosen

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
 
J

John Timney \(Microsoft MVP\)

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top