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

including plain classes in pages

now let's say I have a class that I want to include in all my aspx pages.
It's just a simple class containing some properties and constants. Since
it's not a user control (aka @Register ...) - how would I include it in my
pages? And should I create a .bin assembly for this or just a .cs file?
Nov 17 '05 #1
3 1028
"Daves" <db****@simnet.is> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
now let's say I have a class that I want to include in all my aspx pages.
It's just a simple class containing some properties and constants. Since
it's not a user control (aka @Register ...) - how would I include it in my
pages?
public class CGlobal
{
public static string strSomeGlobalValue()
{
return "Hello world!";
}
}

Then, from anywhere in the rest of your application:

string strHelloWorld = CGlobal.strSomeGlobalValue();
And should I create a .bin assembly for this or just a .cs file?


No need to create a separate assembly.

Alternatively, you could store the values in web.config.
Nov 17 '05 #2
thx - still, if I don't want to type it into every aspx file and even access
it from
PreRequestHandlerExecute event handler... how would I do that smoothly?

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:OK*************@TK2MSFTNGP10.phx.gbl...
"Daves" <db****@simnet.is> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
now let's say I have a class that I want to include in all my aspx pages.
It's just a simple class containing some properties and constants. Since
it's not a user control (aka @Register ...) - how would I include it in
my pages?


public class CGlobal
{
public static string strSomeGlobalValue()
{
return "Hello world!";
}
}

Then, from anywhere in the rest of your application:

string strHelloWorld = CGlobal.strSomeGlobalValue();
And should I create a .bin assembly for this or just a .cs file?


No need to create a separate assembly.

Alternatively, you could store the values in web.config.

Nov 17 '05 #3
"Daves" <db****@simnet.is> wrote in message
news:u8*************@TK2MSFTNGP12.phx.gbl...
thx - still, if I don't want to type it into every aspx file and even
access it from
PreRequestHandlerExecute event handler... how would I do that smoothly?
I appear to have confused you...

You create a *separate* .cs file, name it CGlobal.cs, and add the class
definition to it - you don't add this to every page. In this way, it will be
available to your entire application as and when required.

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:OK*************@TK2MSFTNGP10.phx.gbl...
"Daves" <db****@simnet.is> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
now let's say I have a class that I want to include in all my aspx
pages. It's just a simple class containing some properties and
constants. Since it's not a user control (aka @Register ...) - how would
I include it in my pages?


public class CGlobal
{
public static string strSomeGlobalValue()
{
return "Hello world!";
}
}

Then, from anywhere in the rest of your application:

string strHelloWorld = CGlobal.strSomeGlobalValue();
And should I create a .bin assembly for this or just a .cs file?


No need to create a separate assembly.

Alternatively, you could store the values in web.config.


Nov 17 '05 #4

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

Similar topics

15
by: David | last post by:
is there some way to make a file (.cs) containing some common C# code classes being loaded on every .aspx page in my web without me having to declare it every time? Something in the config file...
3
by: melinda | last post by:
ok, I'm very new to ASP, but familiar with .NET via forms. My company has a fairly large JSP web site, and long term they want to convert it to ASP.net because of various reasons. Anyway, short...
10
by: ptass | last post by:
Hi In asp.net 2.0 an aspx files .cs file is a partial class and all works fine, however, I thought I’d be able to create another class file, call it a partial class and have that compile and...
4
by: Husam | last post by:
Hi Every Body: How can I add the .Net Framework to my setup project? any help will be appreciated. Regard's Husam
10
by: Eric Lindsay | last post by:
This may be too far off topic, however I was looking at this page http://www.hixie.ch/advocacy/xhtml about XHTML problems by Ian Hickson. It is served as text/plain, according to Firefox...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
6
by: Advo | last post by:
Hi Basically, i need to write a php search function which will search all our pages in the directory depending on user keywords.. the thing is, this could be difficult as we may have 8000+...
1
by: Martin Mücke | last post by:
I got a website consisting of about 150 php pages. The site uses a frameless table based design. Header and menu are always the same and therefore should be extracted. At the moment I got a...
7
by: Shelly | last post by:
Please tell me the best way to do this (I am still new to VB.NET and ASPX) as this should very easy for anyone with any experience to answer. In the code behind file (filename.aspx.vb), I import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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...

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.