473,783 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global Function and Variables

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...Cos2Much SpamMakesUFat!
Nov 18 '05 #1
4 1772
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*********@ma kesyoufat.com> wrote in message
news:OC******** ********@TK2MSF TNGP12.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...Cos2Much SpamMakesUFat!

Nov 18 '05 #2
> 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
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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*********@ma kesyoufat.com> wrote in message
news:OC******** ******@TK2MSFTN GP12.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...Cos2Much SpamMakesUFat!

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
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*********@ma kesyoufat.com> wrote in message
news:On******** *****@tk2msftng p13.phx.gbl...
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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*********@ma kesyoufat.com> wrote in message
news:OC******** ******@TK2MSFTN GP12.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...Cos2Much SpamMakesUFat!

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1548
by: Csaba Gabor | last post by:
I'd like to be able to pass a key1/value1 pair into a function and have that function have a local variable by the name of key1 to which value1 is assigned. for example, I'd like to call function sample(oOptions) { var key1 = "key1 default"; var key2 = "key2 default"; var idx; if (arguments.length>0)
3
8118
by: Dalan | last post by:
I need some assistance or advise in composing code for a global function module or a related one for populating values in text boxes on reports and forms with a name, actually several different names. There are over 50 fields in the database requiring name updates and I need to do this several times. And I don't want to use a table/form to perform this task. Here is a bit more information. Yes, I have done the changing of the values in...
12
2584
by: jyu.james | last post by:
I'm trying to detect reads of uninitialized global variables (that are declared in one file, and used in another as an extern). I know that ANSI C initializes all global variables to 0, however, I do not want to rely on this for initialization. Instead, I want to explicity initialize all variables myself. I've looked at tools like Compuware BoundsChecker, which does an amazing job in detecting uninitialized variables, but doesn't...
2
1664
by: Henry | last post by:
Hi guys, I want to write some global functions which can be called from different asp.net page. In Visual Basic, there is a global module which allow me to do that. In Visual Basic .net, I have to create a class file to host these functions. And every time when I need to call these functions, I have to create a object.
0
1442
by: ss | last post by:
i read a few posts about global function access. well i am not interested in global functions. rather, i am seeking for a way to may my call in ASPX pages but not the code behind. for example: in a datagrid bind() in ASPX: <%# container.dataitem("date") %> i'd like to call <%# specialFormat( container.dataitem("date") ) %> I noticed that format from VB is available here.
5
1515
by: Christoph Haas | last post by:
Hi, list... I wondered if it's possible to use global (module) variables as default parameters. A simple working example: ---------------------------------------- #!/usr/bin/python globalvar = 123
4
21716
by: Ming | last post by:
Very frequently, I need to use codes like this to see output clearly: $a=print_r($var,true); echo "<pre>$a</pre>"; How can convert this piece of code to a global function (for example: echopre) in Php so that I can use echopre($data) anywhere in php program (in my server)? Thanks,
3
1783
by: anoop.kn | last post by:
Is there anyway to access Global Function Pointer from its name ? I want to call the function at runtime during a script execution. PS: eval() works, I looking for a more efficient way of doing the same ! Ex: function testfunction ( msg ) { alert( msg );
2
1156
by: Anish Chapagain | last post by:
Hi, I have Structure in C, program and the structure is being used with various function inside C coding but am getting undefined referenced to global method and few of them too uses the sturct module. my problem goes like this, ex.h ----------- #define NIL 0 /* Indicates ptr is nil */ #define NO_CODER 0 /* Means do not use an arithmetic
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9946
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.