views:

746

answers:

5

I have a bunch of ASP.NET web pages (that have a standard layout) that are product documentation. I want to create some sort of combination page that will pull all of the other page content in and concatenate them into one long page.

IFrames won't work because I don't know the size of each page. I could have the combination page do a ton of #includes, and that would work, but I don't want to have to keep the master update to date (we have a database of page names that can change over time).

Ultimately I'm after something that can get a list of pages, and for each one do the equivalent of a #include for that page into the current page.

I hope that makes sense. Any thoughts?

A: 

What does your pages look like?

I assume it's just plain HTMLs and have a consistent pattern across all pages, no? Like, it has proper HTML markup along with HEAD and BODY and such?

In which case you can just read it like you'd read normal text files and do some string parsing on them to extract the part inside BODY tags and then you can just concatenate those and print them out ASP-#include style.

To get the actual path name to a file on an ASP.NET website, you can use Server.MapPath

var actualDiskFilename = Server.MapPath("~/somewhere/somepage.html");

All the System.IO classes work the same in ASP.NET, to fetch a list of files in a virtual directory, you can do:

var virtualDir = "~/somefolder/";
var actualDir = Server.MapPath(virtualDir);

var files = Directory.GetFiles(actualDir);

Is that what you're looking for?

chakrit
+1  A: 

Are your "Documentation Pages" static html or .aspx's also...

if its just static content, you could do the following

//assume that the array of page names has come from the DB.
protected void Page_Load(object sender, EventArgs e)
{
    string[] pages = new string [] { "~/Default.html", 
             "~/Default2.html", "~/Default3.html", "~/Default4.html" };

    foreach (string p in pages)
    {
        Response.WriteFile(p);
    }
}
Eoin Campbell
A: 

If the pages are aspx-documents you can use Server.Execute to execute the page and return the generated html. Then you can parse the html and remove the head- and body-tags and concatenate the remaining html into your page.

Rune Grimstad
A: 

You say IFRAMES won't work because you don't know the sizes? Well why not update the size of the IFRAMES according to the size.

Create a default Size IFRAME and load the page, then by the aid of javascript update the size. You should look at some javascript framework like prototype or jquery

Per Hornshøj-Schierbeck
A: 

Sounds to me like you should rethink the format from the beginning, if possible. If you stored the content in the database or XML files, for instance, then your individual pages could serve up their section, and your conglomerate page could serve up any combination of the total that you want.

Wouldn't be that hard to convert to if you're only talking a few pages (less than a dozen). Then keeping the documentation up to date is a matter of editing the content, not the display files (admittedly, XML is easier than a database in this respect).

sliderhouserules