RE: Custom Page Control

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 01/05/05


Date: Wed, 05 Jan 2005 03:11:13 GMT

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.NET/Easy-ASP.NET-Page-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.)



Relevant Pages

  • Re: Unable to Control Header in html mail
    ... The dialog is correct - you can't preview HTML. ... If I'm following correctly, the header and footers are behaving as expected, ... Teach Yourself Outlook 2003 in 24 Hours ... > page setup all the header and footer areas are blank. ...
    (microsoft.public.outlook.printing)
  • Re: Inserting content control in Word 2007 Footer using Word PIA i
    ... collection contained the content controls from footer as well. ... iterating through StoryRanges perfectly works. ... Besides the main body of the document, header and footers, footnotes, end- ...
    (microsoft.public.word.vba.general)
  • Re: Page inheritance detaches validation script
    ... My method of achieving this was to create custom page controls for the areas ... // add the header... ... // add the footer... ... the validation code can be triggered by controls other than ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Include headers/footers when saving as HTML
    ... Considering that HTML doesn't have any concept of "pages", ... If you want one copy of the header at the top of the web "page" and one copy ... of the footer at the bottom, you'll have to put them there yourself. ...
    (microsoft.public.word.vba.general)
  • Re: Inserting content control in Word 2007 Footer using Word PIA in C#
    ... I could see the same conten control in the collection with the ... Could you please suggest me how I can add it(CC in footer) to ... Besides the main body of the document, header and footers, footnotes, end- ... they already made it so complicated to select individual content controls ...
    (microsoft.public.word.vba.general)