Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. include file

include file

Scheduled Pinned Locked Moved ASP.NET
20 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Christian Graus

    Well, if it's a file that contains css or javascript, put it in a master page, or a base class for all the pages on your site. I was waiting for you to say what it was for, if it was a cs file, for example.

    Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

    S Offline
    S Offline
    Sebastian T Xavier
    wrote on last edited by
    #10

    Thank You very much Sebastian

    1 Reply Last reply
    0
    • S Sebastian T Xavier

      i want to include one file say abc.cs/abc.inc(which contains some global variables and enumerations) in my project. i hope i will be able to do this in html page like File but i would like to include this from the codebehind. Thanks Sebastian

      F Offline
      F Offline
      Fred_Smith
      wrote on last edited by
      #11

      You can use this sort of syntax in your code-behind if you want - and include global variables or functions within it - but place it before (outside of) the tag. Fred </x-turndown>

      S 2 Replies Last reply
      0
      • S Sebastian T Xavier

        i want to include one file say abc.cs/abc.inc(which contains some global variables and enumerations) in my project. i hope i will be able to do this in html page like File but i would like to include this from the codebehind. Thanks Sebastian

        B Offline
        B Offline
        badgrs
        wrote on last edited by
        #12

        Sebastian T Xavier wrote:

        which contains some global variables and enumerations

        Technically there is no such thing as a global variable in .NET - it is Object Oriented and you would do good to go research what OOP is before embarking on an ASP.NET application, especially if your coming from a classic ASP background (which it sounds like you are). Assuming by global you mean you've declared a variable like: (I realise you're probably working in VB.NET but I don't do VB.NET, it sucks) public class MyGlobals { public static readonly string MY_GLOBAL_VAR = "some value"; } To then use this you would simply have to import the namespace with a using statement (if the class is inside another namespace) and reference the variable like: MyGlobals.MY_GLOBAL_VAR;

        S 1 Reply Last reply
        0
        • B badgrs

          Sebastian T Xavier wrote:

          which contains some global variables and enumerations

          Technically there is no such thing as a global variable in .NET - it is Object Oriented and you would do good to go research what OOP is before embarking on an ASP.NET application, especially if your coming from a classic ASP background (which it sounds like you are). Assuming by global you mean you've declared a variable like: (I realise you're probably working in VB.NET but I don't do VB.NET, it sucks) public class MyGlobals { public static readonly string MY_GLOBAL_VAR = "some value"; } To then use this you would simply have to import the namespace with a using statement (if the class is inside another namespace) and reference the variable like: MyGlobals.MY_GLOBAL_VAR;

          S Offline
          S Offline
          Sebastian T Xavier
          wrote on last edited by
          #13

          Hi, Thanks for your reply... I will agree with the concept(static variable). But i am working on webapplication, and i think use of static variables may slow down / cause some performance flaw in the application. Thats why i tried to keep an enumeration in the file and include that in the code behind page.. awaiting for your suggestions Thank you once again Sebastian

          1 Reply Last reply
          0
          • F Fred_Smith

            You can use this sort of syntax in your code-behind if you want - and include global variables or functions within it - but place it before (outside of) the tag. Fred </x-turndown>

            S Offline
            S Offline
            Sebastian T Xavier
            wrote on last edited by
            #14

            i didn't get you. the second step , can you explain this once more thanks sebastian

            1 Reply Last reply
            0
            • F Fred_Smith

              You can use this sort of syntax in your code-behind if you want - and include global variables or functions within it - but place it before (outside of) the tag. Fred </x-turndown>

              S Offline
              S Offline
              Sebastian T Xavier
              wrote on last edited by
              #15

              HI Actully i would like to include this header.inc/header.cs in my code behind page ie. default.aspx.cs// can you show an example.... Thanking you Sebastian

              F 1 Reply Last reply
              0
              • S Sebastian T Xavier

                HI Actully i would like to include this header.inc/header.cs in my code behind page ie. default.aspx.cs// can you show an example.... Thanking you Sebastian

                F Offline
                F Offline
                Fred_Smith
                wrote on last edited by
                #16

                Hello, sorry it was late... The method I was referring to will only work when your code-behind is actually inline and in the same file - ie not such as produced by Visual Studio, where you have separate .aspx and .cs files. If you want to include globally available functions in your code behind in Visual Studio, you should create a separate class file and put them in there as "public" functions. (Solution Explorer --> Add New Item...) cheers Fred

                S 1 Reply Last reply
                0
                • F Fred_Smith

                  Hello, sorry it was late... The method I was referring to will only work when your code-behind is actually inline and in the same file - ie not such as produced by Visual Studio, where you have separate .aspx and .cs files. If you want to include globally available functions in your code behind in Visual Studio, you should create a separate class file and put them in there as "public" functions. (Solution Explorer --> Add New Item...) cheers Fred

                  S Offline
                  S Offline
                  Sebastian T Xavier
                  wrote on last edited by
                  #17

                  Thanks for your reply..... i have seperate file for codebehind, say default.aspx.vb...\ what i am trying to do is to create an enumeration for colour indicators like enum Colours { Blue, Green, Red }; In the UI i will show the colour values in the List Control. when i add or edit the enumeration member, that change should reflect in the UI. This is the scenario..... Once again thanks Sebastian

                  F 1 Reply Last reply
                  0
                  • S Sebastian T Xavier

                    Thanks for your reply..... i have seperate file for codebehind, say default.aspx.vb...\ what i am trying to do is to create an enumeration for colour indicators like enum Colours { Blue, Green, Red }; In the UI i will show the colour values in the List Control. when i add or edit the enumeration member, that change should reflect in the UI. This is the scenario..... Once again thanks Sebastian

                    F Offline
                    F Offline
                    Fred_Smith
                    wrote on last edited by
                    #18

                    If you want this enumeration to be available anywhere in your project (on any page) you need to create a new class (.cs) file and place it in there as a public enumeration - eg public enum Colours { Blue, Green, Red }; To create the class file open Solution Explorer, rifht-click on the root folder of your project and select "Add / Add new Item... " and select the "Class" template - save it with a sensible name. Then add your enumeration to the class and save. You should now be able to reference the enumeration by preceding it with the class name. Frdd

                    S 1 Reply Last reply
                    0
                    • F Fred_Smith

                      If you want this enumeration to be available anywhere in your project (on any page) you need to create a new class (.cs) file and place it in there as a public enumeration - eg public enum Colours { Blue, Green, Red }; To create the class file open Solution Explorer, rifht-click on the root folder of your project and select "Add / Add new Item... " and select the "Class" template - save it with a sensible name. Then add your enumeration to the class and save. You should now be able to reference the enumeration by preceding it with the class name. Frdd

                      S Offline
                      S Offline
                      Sebastian T Xavier
                      wrote on last edited by
                      #19

                      Thank you very much. i got the clear picture... one more time let me disturb you... i have created a file called include.cs and placed in the App_code. created a public enumeration like this.. public enum MyEnum { alfa = 1, beta = 2, gamma = 3 }; let me know how to access this enum and list the vales in a .aspx page i will be thankful to you... sebastian Sebastian

                      F 1 Reply Last reply
                      0
                      • S Sebastian T Xavier

                        Thank you very much. i got the clear picture... one more time let me disturb you... i have created a file called include.cs and placed in the App_code. created a public enumeration like this.. public enum MyEnum { alfa = 1, beta = 2, gamma = 3 }; let me know how to access this enum and list the vales in a .aspx page i will be thankful to you... sebastian Sebastian

                        F Offline
                        F Offline
                        Fred_Smith
                        wrote on last edited by
                        #20

                        reference it as you would any enumeration, just precede it with the class name as it shows in your new .cs file - somehting like: enum include.MyEnum; (Sorry, I'm not an expert in C#) Fred

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups