473,396 Members | 1,833 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,396 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 18 '05 #1
6 1640
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 18 '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 18 '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 18 '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 18 '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 18 '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 18 '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...
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. ...
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....
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.