newbie: asp page templatess

Discussion in 'ASP .Net Web Controls' started by suzy, Jul 29, 2003.

  1. suzy

    suzy Guest

    hi i am quite new to .net and am trying to implement page templates but i
    just cant seem to get it to work, and i dont quite follow the examples on
    the net.

    all i want to do is create a template where i have a header (user control),
    left column, and footer on every page. the remainder of the page will
    change per page.

    can anyone please help? i think i know that i have to create a template.cs
    file which inherits from the page object. and then my aspx page inherits
    from the template.cs object, but the examples seem to confuse me after that.
    suzy, Jul 29, 2003
    #1
    1. Advertising

  2. suzy

    Marcin Guest

    Hi,

    Yes you can inherit from Page class. In your template override
    OnInit() method and load your header and footer controls.

    example:
    protected override void OnInit(EvantArgs args)
    {
    this.Controls.AddAt(0, LoadControl("path to header.ascx " );
    base.OnInit(e);
    this.Controls.Add(LoadControl("path to footer.ascx"));
    }

    Now if any page will inherit from template class it will be wrapped in
    header and footer.

    Regards
    Marcin



    "suzy" <> wrote in message news:<>...
    > hi i am quite new to .net and am trying to implement page templates but i
    > just cant seem to get it to work, and i dont quite follow the examples on
    > the net.
    >
    > all i want to do is create a template where i have a header (user control),
    > left column, and footer on every page. the remainder of the page will
    > change per page.
    >
    > can anyone please help? i think i know that i have to create a template.cs
    > file which inherits from the page object. and then my aspx page inherits
    > from the template.cs object, but the examples seem to confuse me after that.
    Marcin, Jul 29, 2003
    #2
    1. Advertising

  3. suzy

    suzy Guest

    it doesn't work for me.

    the header and footer appear, but not the main content.

    how should i be adding my main content to my main page? and where do the
    html/body/title/etc tags go?

    thanks

    "Marcin" <> wrote in message
    news:...
    > Hi,
    >
    > Yes you can inherit from Page class. In your template override
    > OnInit() method and load your header and footer controls.
    >
    > example:
    > protected override void OnInit(EvantArgs args)
    > {
    > this.Controls.AddAt(0, LoadControl("path to header.ascx " );
    > base.OnInit(e);
    > this.Controls.Add(LoadControl("path to footer.ascx"));
    > }
    >
    > Now if any page will inherit from template class it will be wrapped in
    > header and footer.
    >
    > Regards
    > Marcin
    >
    >
    >
    > "suzy" <> wrote in message

    news:<>...
    > > hi i am quite new to .net and am trying to implement page templates but

    i
    > > just cant seem to get it to work, and i dont quite follow the examples

    on
    > > the net.
    > >
    > > all i want to do is create a template where i have a header (user

    control),
    > > left column, and footer on every page. the remainder of the page will
    > > change per page.
    > >
    > > can anyone please help? i think i know that i have to create a

    template.cs
    > > file which inherits from the page object. and then my aspx page

    inherits
    > > from the template.cs object, but the examples seem to confuse me after

    that.
    suzy, Jul 29, 2003
    #3
  4. suzy

    Marcin Guest

    It should work.

    It will reneder the controls in the following sequence:
    1. header.
    2. your page content (that inherits from PageTemplate)
    3. footer

    All the tags should be placed in such a way that when the page is
    rendered it will generate valid HTML code. For example:
    <html> <head></head> and opening <body> tag could go to the header
    control.
    </body> and </html> could go to your footer. Your page content should
    define only the "inner part" of the page (no <body>,<head> tags
    etc..).

    Good luck.

    Marcin


    "suzy" <> wrote in message news:<#>...
    > it doesn't work for me.
    >
    > the header and footer appear, but not the main content.
    >
    > how should i be adding my main content to my main page? and where do the
    > html/body/title/etc tags go?
    >
    > thanks
    >
    > "Marcin" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Yes you can inherit from Page class. In your template override
    > > OnInit() method and load your header and footer controls.
    > >
    > > example:
    > > protected override void OnInit(EvantArgs args)
    > > {
    > > this.Controls.AddAt(0, LoadControl("path to header.ascx " );
    > > base.OnInit(e);
    > > this.Controls.Add(LoadControl("path to footer.ascx"));
    > > }
    > >
    > > Now if any page will inherit from template class it will be wrapped in
    > > header and footer.
    > >
    > > Regards
    > > Marcin
    > >
    > >
    > >
    > > "suzy" <> wrote in message

    > news:<>...
    > > > hi i am quite new to .net and am trying to implement page templates but

    > i
    > > > just cant seem to get it to work, and i dont quite follow the examples

    > on
    > > > the net.
    > > >
    > > > all i want to do is create a template where i have a header (user

    > control),
    > > > left column, and footer on every page. the remainder of the page will
    > > > change per page.
    > > >
    > > > can anyone please help? i think i know that i have to create a

    > template.cs
    > > > file which inherits from the page object. and then my aspx page

    > inherits
    > > > from the template.cs object, but the examples seem to confuse me after

    > that.
    Marcin, Jul 29, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. suzy

    newbie: asp page templatess

    suzy, Jul 29, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    384
    Marcin
    Jul 29, 2003
  2. Matthew Louden
    Replies:
    4
    Views:
    3,032
    Fahad Al Hadhrami
    Nov 24, 2003
  3. Jozef
    Replies:
    1
    Views:
    424
    Karl Seguin
    May 26, 2005
  4. Chuck
    Replies:
    0
    Views:
    239
    Chuck
    Jul 5, 2003
  5. Divya
    Replies:
    2
    Views:
    180
    Bullschmidt
    May 11, 2004
Loading...

Share This Page