Global Function and Variables

Discussion in 'ASP .Net' started by Simon Harris, May 3, 2004.

  1. Simon Harris

    Simon Harris Guest

    Hi All,

    I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience), just
    one question...

    - Am I correct in thinking that global functions are stored in ASCX files?

    Thanks!

    Simon.

    --
    -
    * Please reply to group for the benefit of all
    * Found the answer to your own question? Post it!
    * Get a useful reply to one of your posts?...post an answer to another one
    * Search first, post later : http://www.google.co.uk/groups
    * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
     
    Simon Harris, May 3, 2004
    #1
    1. Advertising

  2. No you are incorrect.
    But i feel where are you coming from.

    In ASP.NET if you wanted to create reusable HTML element you would create
    file with a global function and include it everywhere.

    And whenever you need that HTML to appear you would call that global
    function.

    Am i correct?

    The User Control(s) - ascx file is much better choice than simple include.
    I would not call it a global function though.


    George.

    "Simon Harris" <> wrote in message
    news:OC%...
    > Hi All,
    >
    > I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience),

    just
    > one question...
    >
    > - Am I correct in thinking that global functions are stored in ASCX files?
    >
    > Thanks!
    >
    > Simon.
    >
    > --
    > -
    > * Please reply to group for the benefit of all
    > * Found the answer to your own question? Post it!
    > * Get a useful reply to one of your posts?...post an answer to another one
    > * Search first, post later : http://www.google.co.uk/groups
    > * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
    >
    >
     
    George Ter-Saakov, May 3, 2004
    #2
    1. Advertising

  3. > I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience), just
    > one question...
    >
    > - Am I correct in thinking that global functions are stored in ASCX files?


    No, ASCX files, or User Controls, contain reusable user interface
    pieces. Check out my article on User Controls for an in-depth
    examination of User Controls:

    An Extensive Examination of User Controls
    http://msdn.microsoft.com/asp.net/u...l=/library/en-us/dnaspp/html/usercontrols.asp

    For information on global variables and functions, check out this article:

    Accessing Common Code, Constants, and Functions in an ASP.NET Project
    http://aspnet.4guysfromrolla.com/articles/122403-1.aspx

    Happy Programming!
     
    Scott Mitchell [MVP], May 3, 2004
    #3
  4. Simon Harris

    Simon Harris Guest

    George/Scott - Thanks! :)
     
    Simon Harris, May 3, 2004
    #4
  5. Hi Simon,

    I would recommend reading up on Object-Oriented programming. The paradigm
    for OOP is entirely different from procedural programming, and unless you
    understand the principles, you will continually be confounded. ASP is
    procedural, meaning that the programming instructions contained in an ASP
    page/script are executed in the order in which they appear in the
    script/page, including the rendering of HTML in the page. ASP.Net is
    Object-oriented, meaning that programming instructions are not in a script
    and are not executed sequentially. Therefore, there is no such thing as a
    "global function." There is Scope, but Scope is defined differently. Rather
    than functions that are simply defined and called as needed, there are
    classes, which are aggregates of data and functionality bundled together in
    an encapsulation. The class is a container, if you will, for these various
    functions and data. It doesn't execute in the procedural sense, but behaves
    more like an object which can be used by another object.

    The term "global," and the concept of Scope in general, are different.
    Members of a class are "global" to the class; that is, they are accessible
    to all class members. A class can have members that are not available
    outside of the class, or to any class which doesn't inherit the class, or
    are visible to any entity outside of the class. These members are scoped as
    Private, Public, Protected, etc. In addition, you have the same general
    types of scope that exist in an ASP application, such as the Application,
    which is globally available to all classes in the application, Session,
    which is global to all page instances of a single user, and so on.

    Again, as ASP.Net is not procedural, it is not hepful to think of functions,
    classes, and other programming objects as being "in files." ASP.Net is not
    scripted, but compiled. Classes and other programming elements reside in
    NameSpaces, and in assemblies. The files are simply a storage container for
    the code. The file is not important; the code is. Object-oriented
    programming is a good bit more abstract than procedural, but once you start
    thinking object-oriented, it all snaps neatly into place.

    In any case, you should be able to see now that a basic understanding of
    Object-Oriented programming principles is essential to writing an ASP.Net
    application.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Simon Harris" <> wrote in message
    news:OC#...
    > Hi All,
    >
    > I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience),

    just
    > one question...
    >
    > - Am I correct in thinking that global functions are stored in ASCX files?
    >
    > Thanks!
    >
    > Simon.
    >
    > --
    > -
    > * Please reply to group for the benefit of all
    > * Found the answer to your own question? Post it!
    > * Get a useful reply to one of your posts?...post an answer to another one
    > * Search first, post later : http://www.google.co.uk/groups
    > * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
    >
    >
     
    Kevin Spencer, May 3, 2004
    #5
  6. Simon Harris

    Simon Harris Guest

    "Kevin Spencer" <> wrote in message
    news:%...
    > Hi Simon,
    >
    > I would recommend reading up on Object-Oriented programming. The paradigm
    > for OOP is entirely different from procedural programming, and unless you
    > understand the principles, you will continually be confounded. ASP is
    > procedural, meaning that the programming instructions contained in an ASP
    > page/script are executed in the order in which they appear in the
    > script/page, including the rendering of HTML in the page. ASP.Net is
    > Object-oriented, meaning that programming instructions are not in a script
    > and are not executed sequentially. Therefore, there is no such thing as a
    > "global function." There is Scope, but Scope is defined differently.

    Rather
    > than functions that are simply defined and called as needed, there are
    > classes, which are aggregates of data and functionality bundled together

    in
    > an encapsulation. The class is a container, if you will, for these various
    > functions and data. It doesn't execute in the procedural sense, but

    behaves
    > more like an object which can be used by another object.
    >
    > The term "global," and the concept of Scope in general, are different.
    > Members of a class are "global" to the class; that is, they are accessible
    > to all class members. A class can have members that are not available
    > outside of the class, or to any class which doesn't inherit the class, or
    > are visible to any entity outside of the class. These members are scoped

    as
    > Private, Public, Protected, etc. In addition, you have the same general
    > types of scope that exist in an ASP application, such as the Application,
    > which is globally available to all classes in the application, Session,
    > which is global to all page instances of a single user, and so on.
    >
    > Again, as ASP.Net is not procedural, it is not hepful to think of

    functions,
    > classes, and other programming objects as being "in files." ASP.Net is not
    > scripted, but compiled. Classes and other programming elements reside in
    > NameSpaces, and in assemblies. The files are simply a storage container

    for
    > the code. The file is not important; the code is. Object-oriented
    > programming is a good bit more abstract than procedural, but once you

    start
    > thinking object-oriented, it all snaps neatly into place.
    >
    > In any case, you should be able to see now that a basic understanding of
    > Object-Oriented programming principles is essential to writing an ASP.Net
    > application.
    >
    > --
    > HTH,
    > Kevin Spencer
    > .Net Developer
    > Microsoft MVP
    > Big things are made up
    > of lots of little things.
    >
    > "Simon Harris" <> wrote in message
    > news:OC#...
    > > Hi All,
    > >
    > > I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience),

    > just
    > > one question...
    > >
    > > - Am I correct in thinking that global functions are stored in ASCX

    files?
    > >
    > > Thanks!
    > >
    > > Simon.
    > >
    > > --
    > > -
    > > * Please reply to group for the benefit of all
    > > * Found the answer to your own question? Post it!
    > > * Get a useful reply to one of your posts?...post an answer to another

    one
    > > * Search first, post later : http://www.google.co.uk/groups
    > > * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
    > >
    > >

    >



    Hi Kevin,

    Thanks for the explanation, I will certainly have a read about OOP
    concepts - It seems your right in that the basic concepts will be helpful in
    making the rest 'snap into place'

    Sounds to me also like ASP.Net is going to be a rather steep learning curve
    for some one with no 'proper' coding knowledge - My experience is solely
    self taught classic ASP and JavaScript over the past 4-5 years, building
    Intranet applications.

    Here goes with some hefty study sessions! :)

    Regards,
    Simon
     
    Simon Harris, May 4, 2004
    #6
  7. Hi Simon,

    A Steep learning curve, yes. Worth the effort? Most definitely! And again,
    once you "get" OOP, the programming paradigm snaps into place pretty well.
    In fact, I consider it easier to work with, more organized, more
    encapsulated. The hard part is finding the functionality you want in the
    CLR. But the .Net SDK, which is a free download, makes that job much easier
    as well. If you want a free copy of the .Net SDK, see:

    http://www.microsoft.com/downloads/...A6-3647-4070-9F41-A333C6B9181D&displaylang=en

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Simon Harris" <> wrote in message
    news:...
    > "Kevin Spencer" <> wrote in message
    > news:%...
    > > Hi Simon,
    > >
    > > I would recommend reading up on Object-Oriented programming. The

    paradigm
    > > for OOP is entirely different from procedural programming, and unless

    you
    > > understand the principles, you will continually be confounded. ASP is
    > > procedural, meaning that the programming instructions contained in an

    ASP
    > > page/script are executed in the order in which they appear in the
    > > script/page, including the rendering of HTML in the page. ASP.Net is
    > > Object-oriented, meaning that programming instructions are not in a

    script
    > > and are not executed sequentially. Therefore, there is no such thing as

    a
    > > "global function." There is Scope, but Scope is defined differently.

    > Rather
    > > than functions that are simply defined and called as needed, there are
    > > classes, which are aggregates of data and functionality bundled together

    > in
    > > an encapsulation. The class is a container, if you will, for these

    various
    > > functions and data. It doesn't execute in the procedural sense, but

    > behaves
    > > more like an object which can be used by another object.
    > >
    > > The term "global," and the concept of Scope in general, are different.
    > > Members of a class are "global" to the class; that is, they are

    accessible
    > > to all class members. A class can have members that are not available
    > > outside of the class, or to any class which doesn't inherit the class,

    or
    > > are visible to any entity outside of the class. These members are scoped

    > as
    > > Private, Public, Protected, etc. In addition, you have the same general
    > > types of scope that exist in an ASP application, such as the

    Application,
    > > which is globally available to all classes in the application, Session,
    > > which is global to all page instances of a single user, and so on.
    > >
    > > Again, as ASP.Net is not procedural, it is not hepful to think of

    > functions,
    > > classes, and other programming objects as being "in files." ASP.Net is

    not
    > > scripted, but compiled. Classes and other programming elements reside in
    > > NameSpaces, and in assemblies. The files are simply a storage container

    > for
    > > the code. The file is not important; the code is. Object-oriented
    > > programming is a good bit more abstract than procedural, but once you

    > start
    > > thinking object-oriented, it all snaps neatly into place.
    > >
    > > In any case, you should be able to see now that a basic understanding of
    > > Object-Oriented programming principles is essential to writing an

    ASP.Net
    > > application.
    > >
    > > --
    > > HTH,
    > > Kevin Spencer
    > > .Net Developer
    > > Microsoft MVP
    > > Big things are made up
    > > of lots of little things.
    > >
    > > "Simon Harris" <> wrote in message
    > > news:OC#...
    > > > Hi All,
    > > >
    > > > I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP

    experience),
    > > just
    > > > one question...
    > > >
    > > > - Am I correct in thinking that global functions are stored in ASCX

    > files?
    > > >
    > > > Thanks!
    > > >
    > > > Simon.
    > > >
    > > > --
    > > > -
    > > > * Please reply to group for the benefit of all
    > > > * Found the answer to your own question? Post it!
    > > > * Get a useful reply to one of your posts?...post an answer to another

    > one
    > > > * Search first, post later : http://www.google.co.uk/groups
    > > > * Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
    > > >
    > > >

    > >

    >
    >
    > Hi Kevin,
    >
    > Thanks for the explanation, I will certainly have a read about OOP
    > concepts - It seems your right in that the basic concepts will be helpful

    in
    > making the rest 'snap into place'
    >
    > Sounds to me also like ASP.Net is going to be a rather steep learning

    curve
    > for some one with no 'proper' coding knowledge - My experience is solely
    > self taught classic ASP and JavaScript over the past 4-5 years, building
    > Intranet applications.
    >
    > Here goes with some hefty study sessions! :)
    >
    > Regards,
    > Simon
    >
    >
     
    Kevin Spencer, May 4, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    499
    Wayne
    Nov 11, 2003
  2. jubelbrus
    Replies:
    5
    Views:
    642
    JohnQ
    Jul 20, 2007
  3. Replies:
    9
    Views:
    1,008
  4. mark4asp
    Replies:
    1
    Views:
    236
  5. king
    Replies:
    2
    Views:
    185
    Tad McClellan
    Jun 27, 2006
Loading...

Share This Page