473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET

Hi All!

I'm developing ASP.NET pages using VB.NET language. My background is VB6 and
ASP3. Right now, I'm evaluating strategies on creating reusable and common
functions and methods for ASP.NET. In ASP 3, it was nothing more than
functions and methods coded in #Include Files. Now ASP.NET offers features
such as Page Inheritance and full software development support.

So I'm just wondering, what should I do if I have 5 functions, that can be
reused (i.e called it) in 10 different ASPX pages, what do I do? Do I create
a model page which contains the classes and inherit them? Or do I just
create a VB file containing all the functions and I can call the functions
from other ASPX pages once I compile them? Or do I create ASCX web controls?
But right now, basically all I need to do is the code only reusable
component and no UI.

Please advice on the best method to create reusable functions and methods
segments for ASP.NET. Also URL pointers on explaining step-by-step
procedures on recommended method(s) will be greatly appreciated!!!

Thanks you all in advance!
Don
Nov 20 '05 #1
6 1488
Both methods will work for you. Inheritance may be the easiest to use and
the simplist but it will depend a bit on what you are doing. If these are
simple functions then the page is great. If they are larger it might be
easier to place them into a class and call it when needed. I tend to use a
combination. I have inherited pages, inherited classes and seperate files
sometimes all within the same app. I know that's not quite what you wanted
to hear but without specifically seeing your usage it's the best I can say.
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Don Wash" <do*@wash.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi All!

I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common
functions and methods for ASP.NET. In ASP 3, it was nothing more than
functions and methods coded in #Include Files. Now ASP.NET offers features
such as Page Inheritance and full software development support.

So I'm just wondering, what should I do if I have 5 functions, that can be
reused (i.e called it) in 10 different ASPX pages, what do I do? Do I create a model page which contains the classes and inherit them? Or do I just
create a VB file containing all the functions and I can call the functions
from other ASPX pages once I compile them? Or do I create ASCX web controls? But right now, basically all I need to do is the code only reusable
component and no UI.

Please advice on the best method to create reusable functions and methods
segments for ASP.NET. Also URL pointers on explaining step-by-step
procedures on recommended method(s) will be greatly appreciated!!!

Thanks you all in advance!
Don

Nov 20 '05 #2
Hi Curt,

Thanks for the quick reply! I have some functions which are logical enough
to put them into one class and some "ad-hoc" functions and variables that
many pages in my website (Not All) needed.

So any ideas? (Also any pointers to tutorials or step-by-step for the
recommended method?)

Cheers!
Don

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Both methods will work for you. Inheritance may be the easiest to use and
the simplist but it will depend a bit on what you are doing. If these are
simple functions then the page is great. If they are larger it might be
easier to place them into a class and call it when needed. I tend to use a
combination. I have inherited pages, inherited classes and seperate files
sometimes all within the same app. I know that's not quite what you wanted
to hear but without specifically seeing your usage it's the best I can say.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Don Wash" <do*@wash.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi All!

I'm developing ASP.NET pages using VB.NET language. My background is VB6

and
ASP3. Right now, I'm evaluating strategies on creating reusable and common functions and methods for ASP.NET. In ASP 3, it was nothing more than
functions and methods coded in #Include Files. Now ASP.NET offers features such as Page Inheritance and full software development support.

So I'm just wondering, what should I do if I have 5 functions, that can be reused (i.e called it) in 10 different ASPX pages, what do I do? Do I

create
a model page which contains the classes and inherit them? Or do I just
create a VB file containing all the functions and I can call the functions from other ASPX pages once I compile them? Or do I create ASCX web

controls?
But right now, basically all I need to do is the code only reusable
component and no UI.

Please advice on the best method to create reusable functions and methods segments for ASP.NET. Also URL pointers on explaining step-by-step
procedures on recommended method(s) will be greatly appreciated!!!

Thanks you all in advance!
Don


Nov 20 '05 #3
I'd probably go with page inheritance in your case.
Simple enough. Just put all these functions in the code on one master page
that derives from the standard page class.
Then on all your pages in the code add your "master" as the class you
inherit from instead of the Page class.
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Don Wash" <do*@wash.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
Hi Curt,

Thanks for the quick reply! I have some functions which are logical enough
to put them into one class and some "ad-hoc" functions and variables that
many pages in my website (Not All) needed.

So any ideas? (Also any pointers to tutorials or step-by-step for the
recommended method?)

Cheers!
Don

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Both methods will work for you. Inheritance may be the easiest to use and
the simplist but it will depend a bit on what you are doing. If these are simple functions then the page is great. If they are larger it might be
easier to place them into a class and call it when needed. I tend to use a combination. I have inherited pages, inherited classes and seperate files sometimes all within the same app. I know that's not quite what you wanted to hear but without specifically seeing your usage it's the best I can say.


--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Don Wash" <do*@wash.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi All!

I'm developing ASP.NET pages using VB.NET language. My background is
VB6 and
ASP3. Right now, I'm evaluating strategies on creating reusable and

common functions and methods for ASP.NET. In ASP 3, it was nothing more than
functions and methods coded in #Include Files. Now ASP.NET offers features such as Page Inheritance and full software development support.

So I'm just wondering, what should I do if I have 5 functions, that
can be reused (i.e called it) in 10 different ASPX pages, what do I do? Do I

create
a model page which contains the classes and inherit them? Or do I just
create a VB file containing all the functions and I can call the functions from other ASPX pages once I compile them? Or do I create ASCX web

controls?
But right now, basically all I need to do is the code only reusable
component and no UI.

Please advice on the best method to create reusable functions and methods segments for ASP.NET. Also URL pointers on explaining step-by-step
procedures on recommended method(s) will be greatly appreciated!!!

Thanks you all in advance!
Don



Nov 20 '05 #4
You can also just create static functions

eg

public class ConstantFunctions
{
public static void SetSelectedItem(ref
System.Web.UI.WebControls.DropDownList oDrop, string val)

{

System.Web.UI.WebControls.ListItem li = oDrop.Items.FindByValue(val);

if (li == null)

{

oDrop.SelectedIndex = 0;

}

else

{

li.Selected = true;

}

}

}
"Don Wash" <do*@wash.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi All!

I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common
functions and methods for ASP.NET. In ASP 3, it was nothing more than
functions and methods coded in #Include Files. Now ASP.NET offers features
such as Page Inheritance and full software development support.

So I'm just wondering, what should I do if I have 5 functions, that can be
reused (i.e called it) in 10 different ASPX pages, what do I do? Do I create a model page which contains the classes and inherit them? Or do I just
create a VB file containing all the functions and I can call the functions
from other ASPX pages once I compile them? Or do I create ASCX web controls? But right now, basically all I need to do is the code only reusable
component and no UI.

Please advice on the best method to create reusable functions and methods
segments for ASP.NET. Also URL pointers on explaining step-by-step
procedures on recommended method(s) will be greatly appreciated!!!

Thanks you all in advance!
Don

Nov 20 '05 #5
"Don Wash" <do*@wash.com> wrote in
news:uP*************@TK2MSFTNGP12.phx.gbl:
Or do I just
create a VB file containing all the functions and I can call the
functions from other ASPX pages once I compile them?


This will probably be the easiest method. Create a VB Class which you can
use in other pages.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #6
Wait for VS2005 which has the master page concept with content placeholders,
and web parts for portal development.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Don Wash" <do*@wash.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
Hi Curt,

Thanks for the quick reply! I have some functions which are logical enough
to put them into one class and some "ad-hoc" functions and variables that
many pages in my website (Not All) needed.

So any ideas? (Also any pointers to tutorials or step-by-step for the
recommended method?)

Cheers!
Don

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Both methods will work for you. Inheritance may be the easiest to use and
the simplist but it will depend a bit on what you are doing. If these are simple functions then the page is great. If they are larger it might be
easier to place them into a class and call it when needed. I tend to use a combination. I have inherited pages, inherited classes and seperate files sometimes all within the same app. I know that's not quite what you wanted to hear but without specifically seeing your usage it's the best I can say.


--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Don Wash" <do*@wash.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi All!

I'm developing ASP.NET pages using VB.NET language. My background is
VB6 and
ASP3. Right now, I'm evaluating strategies on creating reusable and

common functions and methods for ASP.NET. In ASP 3, it was nothing more than
functions and methods coded in #Include Files. Now ASP.NET offers features such as Page Inheritance and full software development support.

So I'm just wondering, what should I do if I have 5 functions, that
can be reused (i.e called it) in 10 different ASPX pages, what do I do? Do I

create
a model page which contains the classes and inherit them? Or do I just
create a VB file containing all the functions and I can call the functions from other ASPX pages once I compile them? Or do I create ASCX web

controls?
But right now, basically all I need to do is the code only reusable
component and no UI.

Please advice on the best method to create reusable functions and methods segments for ASP.NET. Also URL pointers on explaining step-by-step
procedures on recommended method(s) will be greatly appreciated!!!

Thanks you all in advance!
Don



Nov 20 '05 #7

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

Similar topics

11
by: Matt | last post by:
I have object/machine code in static library (written and compiled using C++) that I wish to make difficult to reverse-engineer. I am told by others that some could reverse-engineer this...
6
by: BigMan | last post by:
I've come to the decision to use multiple namespaces for a very specific reason: I like to use descriptive names of UDTs and I sometimes come up with long UDT names (and file names too, since I...
10
by: Rada Chirkova | last post by:
Hi, at NC State University, my students and I are working on a project called "self-organizing databases," please see description below. I would like to use an open-source database system for...
6
by: Don Wash | last post by:
Hi All! I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common functions and methods for ASP.NET....
5
by: wrecker | last post by:
Hi all, I have a few common methods that I need to use at different points in my web application. I'm wondering where the best place would be to put these? I think that I have three options. ...
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
1
by: CES | last post by:
All, I was wondering if someone could point me to a tutorial on creating & accessing functions from within a wrapper function. I've created a group of functions related to a timer event. All...
13
by: Tony | last post by:
And that is probably very unclear - so let me explain. Please forgive me if I screw up the terminology (and let me know what the correct term would be): What I want to do is to create a library...
4
by: Brian Blais | last post by:
Hello, I am trying to organize some of my code, and am having a little trouble with the import logic. I find I often have something like: MyPackage/ Part1/ # wants to use functions in...
2
by: bukzor | last post by:
I've been finding at work that I've written a set of functions several times, sometimes with more or less features or bugs, so I've decided to take my small, useful functions and put them in some...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.