Reputation: 1410
We have used classic ASP at my office for years and are transitioning to ASP.NET. The way menus have been done was always by using an "include" statement, and including an html file for the menu (along with some other things). Obviously with .NET master pages are the answer, but the problem that arises is when we add a new project that wants to basically share a menu with the older classic ASP projects. Currently we use Master Pages for the new project and have to update both files/menus when a change is needed.
I know about Response.WriteFile() but I am not able to get it to work based on the folder structure (as far as I know). For example, I've tried to use the following on my .NET master page to access the classic menu:
<%
Response.WriteFile ("../menufolder/menu_body.htm");
%>
With the folder structures looking like, for example, this:
../ClassicASPfolder/menufolder/menu_body.htm AND
../ClassicASPfolder/apps/ASPNETfolder/masterpage.aspx
This "leaves" the .NET project folder though, and I am guessing that is where the problem lies. Is there something I am missing in regards to the folder structure, or a better solution where we can keep our existing html menus and simply "include" them so that we don't have to maintain two separate menus?
EDIT:
Looking back at my question and considering the XY Problem, is there a solution to "include" htm files as a menu separate from using Response.Write() that works better? (I am still interested in knowing about the Response.Write folder structure regardless of the solution)
Code for the menu: (the "WebRoot" is currently set from a separate include file, but that can be changed)
<div id="MenuContent">
<div id="Wrapper">
<div id="Menu">
<a id="1" href="<%=WebRoot%>/home.asp">Home</a>
<a id="2" href="<%=WebRoot%>/directory.asp">Directory</a>
<a id="3" href="<%=WebRoot%>/faq.asp">FAQ</a>
<a id="4" href="<%=WebRoot%>/information.asp">Information</a>
</div>
</div>
</div>
Upvotes: 0
Views: 360
Reputation: 3555
I don't know that much about Classic ASP, but here are my 2 suggestions:
If you want to keep using your existing menu, you can use a prebuild step to copy the menufile over to the new folder. these are the steps:
copy
statement. The syntax is the same as you use when entering a command line statement in cmd.exe. I'd start with this syntax:copy "$(SolutionDir)....\menufolder\menu_body.htm" "$(SolutionDir)menu_body.htm"
This command (untested) should copy the file to the root folder of your asp.net solution. When you enter it in the pre-build events, it does this before the project is built, if you do it in the postbuild, it will happen after the project is built. You only have to edit the one from classic ASP and it will automatically be copied to the new location whenever you build your ASP.NET project.
A second option, which won't be automatic and is not portable, but which is what I recommend heartily, is to use the ASP.NET menu control. the ASP.NET menu control allows you more control over your menu without having to worry about your div locations. And because it's default ASP.NET, it fully integrates with your codebehind class. http://msdn.microsoft.com/en-us/library/ecs0x9w5(VS.80).aspx explains how to use it.
The main issue with this is that it means you cannot reuse your existing .htm file. however, you can use an ASP.NET sitemap file to automatically generate your menu, keeping it up to date with whatever changes you make to your website.
Upvotes: 1