whats the best way to?

  • Thread starter Thread starter Guy Bradley
  • Start date Start date
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
 
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.
 
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.
 
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
 
Back
Top