HighTechTalks DotNet Forums  

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

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Don Wash
 
Posts: n/a

Default HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-04-2004 , 09:40 PM






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



Reply With Quote
  #2  
Old   
Curt_C [MVP]
 
Posts: n/a

Default Re: HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-04-2004 , 09:48 PM






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" <don (AT) wash (DOT) com> wrote

Quote:
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





Reply With Quote
  #3  
Old   
Don Wash
 
Posts: n/a

Default Re: HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-04-2004 , 09:58 PM



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

Quote:
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" <don (AT) wash (DOT) com> wrote in message
news:uPJKK1oeEHA.636 (AT) TK2MSFTNGP12 (DOT) 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







Reply With Quote
  #4  
Old   
Curt_C [MVP]
 
Posts: n/a

Default Re: HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-04-2004 , 10:26 PM



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" <don (AT) wash (DOT) com> wrote

Quote:
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:%23ggzD5oeEHA.1656 (AT) TK2MSFTNGP09 (DOT) 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" <don (AT) wash (DOT) com> wrote in message
news:uPJKK1oeEHA.636 (AT) TK2MSFTNGP12 (DOT) 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









Reply With Quote
  #5  
Old   
Darren Clark
 
Posts: n/a

Default Re: HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-04-2004 , 11:39 PM



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" <don (AT) wash (DOT) com> wrote

Quote:
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





Reply With Quote
  #6  
Old   
Lucas Tam
 
Posts: n/a

Default Re: HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-05-2004 , 12:56 AM



"Don Wash" <don (AT) wash (DOT) com> wrote in
news:uPJKK1oeEHA.636 (AT) TK2MSFTNGP12 (DOT) phx.gbl:

Quote:
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 (REMOVEnntp (AT) rogers (DOT) com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Reply With Quote
  #7  
Old   
One Handed Man \( OHM - Terry Burns \)
 
Posts: n/a

Default Re: HOWTO: Creating and Organizing Reuseable or Common Methods and Functions for ASP.NET - 08-05-2004 , 03:32 AM



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" <don (AT) wash (DOT) com> wrote

Quote:
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:%23ggzD5oeEHA.1656 (AT) TK2MSFTNGP09 (DOT) 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" <don (AT) wash (DOT) com> wrote in message
news:uPJKK1oeEHA.636 (AT) TK2MSFTNGP12 (DOT) 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









Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.