issues w/ standarizing client side/server side includes...

I have been searching for a way to standardized my include files in C# -- both server side and client side.

Client Side Issues--
Adding a javascript file with a few reusable functions is easy. However, when adding it into a VS .NET project causes me issues. The complier attempts to compile it -- and naturally it FAILS. It doesn't know what the word 'function' means (among many other terms). So i'm stuck with either removing the file from the project, but leaving it within the project file structure. I don't like this approach because it causes isses with updating and source safe. I could make sense of it -- but i don't want to explain these steps to my team -- it's very sloppy in my opionon. The second option is to copy all the functions to each page within the website. I lose my ability to have one location for reusable functions.

Is there a way to have the compiler ignore certain files? I'm running out of ideas.

Server Side Includes-
I wish i didn't have to delcare a class for reusable functions that have no business being in a class. Even just declaring static functions within a namespace would be acceptable. Include the name space and *presto* you have all you're function available without having to reference them by the class name -- but alas that doesn't work. Any workaround for this?

Also, server side includes in an ASPX suffer from the same issue as a client side javascript include. The ASPX file is able to include the file and use all the included functions, but i'm not able to include it into the project. A set of functions just standing there in a .CS file without a class wrappering them throws compiler errors.

Any ideas?

Thanks
Jibran

[1744 byte] By [jibran] at [2007-12-16]
# 1
I can answer the second one.

C#, by design, requires all functions to exist as a member of some type of object, often a class. Open functions are prone to collusions.

Many people use a static class called "Utility", that contains the various small utility functions that don't make sense anywhere else.

For the first issue, I've heard of this but don't have any personal experience. You may be able to change the compilation options in the properties pane to "none" instead of "compile", but I'm not sure if this is possible with the changes to the way ASP.NET works. If nothing else, renaming the .js file to have some other extension should do the trick.

-Ryan / Kardax

RyanLamansky at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...
# 2
Thanks for the reply Ryan. Shortly after I posted my issue I DID stumble upon the properties of an individual file (right click -> properties). Changing the build action from "compile" to "none" works just fine. I am able to include the file in the project and the compiler ignores it. So this solved my issue for both server side and client side includes.

Changing the extension of the file, however, doesn't work. VS .net compiles it anyways (based on what language you're programming in).

jibran at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...