whats the best way to?

Discussion in 'ASP .Net' started by Guy Bradley, Aug 5, 2003.

  1. Guy Bradley

    Guy Bradley Guest

    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
     
    Guy Bradley, Aug 5, 2003
    #1
    1. Advertisements

  2. 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.
     
    Steve C. Orr, MCSD, Aug 5, 2003
    #2
    1. Advertisements

  3. 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.
     
    Kevin Spencer, Aug 5, 2003
    #3
  4. 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
     
    Jay Warmack, MCAD, Aug 5, 2003
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.