473,657 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing functions defined in Global.asax

Hi,
I have defined a function in global.asax file. Could somebody please
tell me how i am supposed to call that function from the other files
of the same project.
Global.asax
public function getName() as String
dim name as string
name = "Abc"
return name
end function
myfile01.aspx
'How do I call that function from this file. Am I supposed to import
something?
Thanks in advance for this help
Anjali
Nov 18 '05 #1
3 7133
You can get a reference to the class and call the methods.By default the
class in Global.asax is named Global

Example:

Dim objGlobal as Global=New Global()

Dim strResult as string= objGlobal.getNa me()

If u wish to avoid making instance of the class u can define getName as a
static function

"Anjali Lourda" <an****@panteq. com> wrote in message
news:a3******** *************** ***@posting.goo gle.com...
Hi,
I have defined a function in global.asax file. Could somebody please
tell me how i am supposed to call that function from the other files
of the same project.
Global.asax
public function getName() as String
dim name as string
name = "Abc"
return name
end function
myfile01.aspx
'How do I call that function from this file. Am I supposed to import
something?
Thanks in advance for this help
Anjali

Nov 18 '05 #2
Hi Anjali,

If your going to make global functions available to your application its
probably better to consolidate all your code into a DLL, stick it in your
/bin directory, and then reference it from your ASP.NET pages.

"Anjali Lourda" <an****@panteq. com> wrote in message
news:a3******** *************** ***@posting.goo gle.com...
Hi,
I have defined a function in global.asax file. Could somebody please
tell me how i am supposed to call that function from the other files
of the same project.
Global.asax
public function getName() as String
dim name as string
name = "Abc"
return name
end function
myfile01.aspx
'How do I call that function from this file. Am I supposed to import
something?
Thanks in advance for this help
Anjali

Nov 18 '05 #3
Anjali Lourda wrote:
Hi,
I have defined a function in global.asax file. Could somebody please
tell me how i am supposed to call that function from the other files
of the same project.
Global.asax
public function getName() as String
dim name as string
name = "Abc"
return name
end function
myfile01.aspx
'How do I call that function from this file. Am I supposed to import
something?


You could call a function defined in global.asax but you would be *much*
better off creating a class with a static method and referencing the
method that way. This is the purpose of code-behind.

--
Ryan Walberg, B.Sc., MCSD, MCSD for .NET
ge*******@nospa m.yahoo.com.nos pam
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
6760
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what that means and all, but what I'm wondering is what's the best way around it? Say, for example, I want a function that takes a username and a password and returns true or false if it's a successful login, and I want any page or usercontrol in the...
2
2604
by: Ekul | last post by:
I have an application that allows users to login and logout. I track how many users are logged in and when each individual is logged in. The application will not allow concurrent logins(let a user log in twice at the same time). My problem is I am having trouble telling when the user is logged off. If they click the logout button everything works fine. But if the close the browser by clicking the x or navigate to another url through the...
2
5200
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb file, and what would I do to access it? (I am using VB.NET for my code) Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
1
2225
by: | last post by:
Hi all, Is it possible to have custom function/subroutines in global.asax? e.g. DoMyWork(i as integer) etc etc. If yes, how can I access this code in my ..aspx pages? I know I can put this into a seperate dll in the bin directory, but to keep it simple global.asax would be nice too.. TIA!
11
8354
by: Ron | last post by:
I have a web project compiled with the new "Web Deployment Projects" plugin for VS2005. I'm deploying the web project to one assembly and with updateable option set to ON. When I'm running the generated code on a W2K3 server the application_start and any other event on the global.asax file won't fire. I added tracing and logging to make sure and I can see the code is just not execution. When running the same exact (deployed etc.) code on...
2
1893
by: rgparkins | last post by:
Hi Guys Maybe a simple and easy solution to this, but I keep getting exception object not set to instance etc etc. I have a Timer that is initiated in Application_Start in Global.asax. This timer I am using as a service every 10 minutes to send email to users. OK so all is fine until I need to load a file from the server (in fact an email template).
10
2354
by: Nemisis | last post by:
Hi everyone, I am trying to create a custom error page, that the user gets shown when a error has occurred within my website. The code works perfectly, apart from when an invalid URL is typed in, then i am unable to pass the exception from the global.asax file to the page via the sessionstate. Everytime i try to pass something into the sessionstate i get a error message of 'Object reference not set to an instance of an object.'
3
2627
by: David | last post by:
Hi, I have seen in some site implementations code has been entered into global.asax.cs in its own function, not any of the regular application or session functions that exist in here. What I want to be able to do is to have workflow in my project. The workflow may be extended by future programmers by adding code into the global.asax.cs file. The code should be optional, i.e. if the function does not exist (even by name) then my code...
12
1808
by: reubendb | last post by:
Hello, I am new to Python. I have the following question / problem. I have a visualization software with command-line interface (CLI), which essentially is a Python (v. 2.5) interpreter with functions added to the global namespace. I would like to keep my own functions in a separate module and then import that module to the main script (that will be executed using the CLI interpreter). The problem is, I cannot access the functions in the...
0
8305
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
8823
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...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
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
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1604
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.