Professional Web Applications Themes

newbie: asp page templatess - ASP.NET General

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 ...

  1. #1

    Default newbie: asp page templatess

    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 Guest

  2. #2

    Default Re: newbie: asp page templatess

    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" <menospam.com> wrote in message news:<uS3ZEPbVDHA.2328TK2MSFTNGP12.phx.gbl>...
    > 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 Guest

  3. #3

    Default Re: newbie: asp page templatess

    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" <m_nowo2.pl> wrote in message
    news:d71a96eb.0307290620.4da3279aposting.google.c om...
    > 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" <menospam.com> wrote in message
    news:<uS3ZEPbVDHA.2328TK2MSFTNGP12.phx.gbl>...
    > > 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 Guest

  4. #4

    Default Re: newbie: asp page templatess

    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" <menospam.com> wrote in message news:<#VdwR3eVDHA.1948TK2MSFTNGP11.phx.gbl>...
    > 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" <m_nowo2.pl> wrote in message
    > news:d71a96eb.0307290620.4da3279aposting.google.c om...
    > > 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" <menospam.com> wrote in message
    > news:<uS3ZEPbVDHA.2328TK2MSFTNGP12.phx.gbl>...
    > > > 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 Guest

Similar Threads

  1. Newbie, pulling a video from another web page
    By xdude in forum ASP.NET Building Controls
    Replies: 1
    Last Post: November 11th, 08:56 PM
  2. Newbie trying to add a jpg to exsisting page
    By fatfenders in forum Macromedia Contribute General Discussion
    Replies: 1
    Last Post: October 12th, 06:58 PM
  3. 2 SQL queries in 1 asp page -- Newbie
    By Micromanaged in forum ASP Database
    Replies: 3
    Last Post: June 16th, 06:50 PM
  4. Newbie Question - Two on One Page
    By Marcus Cuttino in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: May 6th, 01:19 PM
  5. Insert page error (asp newbie)
    By Amiddlet webforumsuser@macromedia.com in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: September 28th, 07:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139