whats the best way to?

G

Guy Bradley

write one function (for navigation) and call it in multiple asp.net pages? -
i would use an include file as i do in asp but i gather this isnt the best
way of doing it...

suggestion? - thx in advance
 
S

Steve C. Orr, MCSD

Create a class. Instantiate it where you need it.
Another approach would be to create a user control or custom control. This
would likely be a better approach if common UI is involved.
 
K

Kevin Spencer

Yes, in fact, you can often create a static method of a class, so that it
isn't even necessary to instantiate the class to use the method.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.
 
J

Jay Warmack, MCAD

Guy,

Since UI is involved (rather than just business logic), I would suggest
creating your own page object (inherit from Page) and then inherit all your
pages from this new page object (instead of Page). Then all the protected
and public methods and properties that you add to your page object will be
available to all or your descendant pages. This method even allows you to
add code to the page object's Page_Load event to 'hardwire' the execution of
your navigation methods so that you don't even write any navigation code at
all in the descendant pages. Starting to solve things this way is the
first step to thinking OO instead of Cut-and-Paste (or Include in this
case).

Jay Warmack, MCAD
..Net Consultant
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top