Results 1 to 4 of 4

Thread: Include block of code

  1. #1
    Join Date
    May 2005

    Include block of code

    I have a big block of code that I am using as a navigation bar for my site. I am constantly changing it though. Is there some way to save it all in one file and then include it in each page so that I don't have to change it multiple times every time I want to edit it? I am building it using ASP.net on VWD 2005 Beta 2.


  2. #2
    Join Date
    Nov 2002
    Auburn, AL
    You want to include server side code? I would say just use a class or a code behind.

  3. #3
    Join Date
    May 2004
    Perth, WA
    Yes, it is very common to do this.

    You need to use either a User Control or a Server Control.

    There are different strengths for each of these options. If you want to read more about these strengths and weaknesses then go here:


    I think the main issue will be that if you want the navigation bar to be dynamic then you will want to use a server control otherwise it may be more simple to just create a User Control.

    To learn how to create and include a User Control in a page go here:


    Good Luck AConnorABBCO

  4. #4
    Join Date
    Jun 2005
    Yes, User Control is the way to go. Simpler to create than Server Control. Think of them as "smart include files" (if you are familiar with classic ASP server side includes).

    For instance, on http://www.geewebtools.com, the top nav is a User Control complete with encapsulated javascript to handle the rollovers.

    Goto http://www.geewebtools.com/web-content-management/ - the nav buttons "overview"..."demo" are done with one user control object with different attributes set in the html tag declaration for each of our 25 modules to determine its behavior.

    Once you start with User Controls in .NET, you will love them.
    Gee! Web Tools
    Web Content Management / Internet Marketing Tools including:
    Page Editor - Calendar Manager - News Editor - Mail Wizard

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles