Re: C# Website - Global Functions
From: Nick Malik [Microsoft] (nickmalik_at_hotmail.nospam.com)
Date: 02/27/05
- Next message: DotNetJunky: "Dynamically adding DropDownList - if I set ID also, I lose PostBack EventHandler"
- Previous message: Peter Wone: "Re: Data Records from Flat File (COBOL Style)"
- In reply to: David P. Donahue: "C# Website - Global Functions"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 26 Feb 2005 22:22:42 -0800
Assuming you are using Visual Studio and are writing your app using
code-behinds, then simply create a class in any *.cs file in the project, or
create a new *.cs file in the project. Any page can simply create the
object and call the method, or, if you declare the method as "static" then
any code can simply call the method without creating an object first.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"David P. Donahue" <ddonahue@ccs.neu.edu> wrote in message
news:ONe3M$0GFHA.3484@TK2MSFTNGP12.phx.gbl...
> 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 website to be able to call that function, where should I put it and
> what syntax do I need?
>
>
> Regards,
> David P. Donahue
> ddonahue@ccs.neu.edu
- Next message: DotNetJunky: "Dynamically adding DropDownList - if I set ID also, I lose PostBack EventHandler"
- Previous message: Peter Wone: "Re: Data Records from Flat File (COBOL Style)"
- In reply to: David P. Donahue: "C# Website - Global Functions"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|