473,804 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1534
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******** *****@TK2MSFTNG P12.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_da rkfalz.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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******** *****@TK2MSFTNG P12.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******** ******@TK2MSFTN GP09.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_da rkfalz.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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******** *****@TK2MSFTNG P12.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 ConstantFunctio ns
{
public static void SetSelectedItem (ref
System.Web.UI.W ebControls.Drop DownList oDrop, string val)

{

System.Web.UI.W ebControls.List Item li = oDrop.Items.Fin dByValue(val);

if (li == null)

{

oDrop.SelectedI ndex = 0;

}

else

{

li.Selected = true;

}

}

}
"Don Wash" <do*@wash.com > wrote in message
news:uP******** *****@TK2MSFTNG P12.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******** *****@TK2MSFTNG P12.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********@rog ers.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******** ******@TK2MSFTN GP09.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_da rkfalz.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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******** *****@TK2MSFTNG P12.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
4115
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 object/machine code to generate some or all of the source, and while it may not be a trivial task, it would not be impossible. Do tools, processes, or other means exist by which I could do this? I'm looking for something analogous to code obfuscation...
6
1635
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 name a source file after the UDT that is defined in it, if any). I've also noticed, however, that certain types are related more than logically but also lexically - they start with the same word (which happens to be the basic concept that they...
10
3263
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 implementation and would really appreciate your opinion on whether PostgreSQL is suitable for the project. In general, I am very impressed by the quality of PostgreSQL code and documentation, as well as by the support of the developer community. ...
6
1676
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. 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...
5
3204
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. 1. I can create a common module like common.vb in my project and put all the functions in there. 2. Create a utility class and create the common functions as shared
4
2862
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. '**************************************************************************** ' Issues '****************************************************************************
1
2534
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 works well until I try to enclose these functions into a class like structure ie: function dTimer(div){ //Insert the Javascript Code Below startTimer(); }
13
1563
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 'namespace' to encapsulate certain functions that have something in common. I want it to work in the way the Math() object works - by calling it directly, instead of having to instantiate it as a variable (object?) For example, with the Math...
4
1410
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 Common/ __init__.py # does "from MyClass1 import MyClass1", etc,... MyClass1.py MyClass1a.py # depends on MyClass1
2
1268
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 common place. I've made a module for this, but it is quickly becoming a jumbled mess of unrelated functions. Also the one class that I've written with inheritance takes up fully 1/3 of the documentation (compared to 20 other functions). Since this...
0
9710
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
10593
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
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10085
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
6858
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
5527
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
3
3000
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.