Include block of code

windows

Guest
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.

Thanks,
AndrewYou want to include server side code? I would say just use a class or a code behind.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:

<!-- m --><a class="postlink" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwebusercontrolsvscustomwebcontrols.asp">http://msdn.microsoft.com/library/defau ... ntrols.asp</a><!-- m -->

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:

<!-- m --><a class="postlink" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconincludingpageletcontrolinanotherwebformspage.asp">http://msdn.microsoft.com/library/defau ... mspage.asp</a><!-- m -->

Good Luck AConnorABBCO :)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 <!-- m --><a class="postlink" href="http://www.geewebtools.com">http://www.geewebtools.com</a><!-- m -->, the top nav is a User Control complete with encapsulated javascript to handle the rollovers.

Goto <!-- m --><a class="postlink" href="http://www.geewebtools.com/web-content-management/">http://www.geewebtools.com/web-content-management/</a><!-- m --> - 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.
 
Back
Top