Hi James,
From your description, you're wanting to generate a base page class which
will output some common Page Header or Footer html contents on all the
derived pages, yes?
As for the problem you encountered, I think we have the following approachs:
1. Don't change our derived pages' aspx template, and just make use the
base page's Render method. We can use the base.Render to get the page's
default output html content and them locate the <body>...</body> section
and insert our header and footer in it(maybe around the <form> ..</form>).
Such as :
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
HtmlTextWriter htw = new HtmlTextWriter(new StringWriter(sb));
base.Render(htw);
//parse the sb.ToString() and modify it
}
We may need to use regex to do some string parsing.
2. We can also use OO based page inheritance and make the footer and header
as controls in the page's control collection and put all the controls in
derived page inside our base page's Form control.
Here are some tech article dicusssing on such approachs:
#Easy ASP.NET Page Templates
http://www.devarticles.com/c/a/ASP.N...e-Templates/1/
#Do more with your ASP.NET Page Template
http://www.codeproject.com/aspnet/pagetemplates.asp
However, this may need us to modify our derived page's aspx template so as
not to include <html> <body> tags in it.
Hope these help. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)