By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,462 Members | 799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,462 IT Pros & Developers. It's quick & easy.

Global Function and Variables

P: n/a
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!
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <to*********@makesyoufat.com> wrote in message
news:OC****************@TK2MSFTNGP12.phx.gbl...
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!

Nov 18 '05 #2

P: n/a
> 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/us...ercontrols.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!
Nov 18 '05 #3

P: n/a
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <to*********@makesyoufat.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
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
Nov 18 '05 #4

P: n/a
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/d...displaylang=en

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

"Simon Harris" <to*********@makesyoufat.com> wrote in message
news:On*************@tk2msftngp13.phx.gbl...
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <to*********@makesyoufat.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.