newbie: asp page templatess

Ask a Question related to ASP.NET General, Design and Development.

  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. Similar Questions and Discussions

    1. Newbie trying to add a jpg to exsisting page
      Have been playing around trying to figure out how to add a new .jpg to a page on an exsisting website. There are exsisting .jpgs on that page. When...
    2. 2 SQL queries in 1 asp page -- Newbie
      I am trying to run 2 queries against a Access2k database on a single ASP page. I have one query working beautifully, but am not sure how to...
    3. Newbie Question - Two on One Page
      How do I use acrobat and change my pdf so that I have two of the same document on one page. Do I need a plugin and if so which one? All help is...
    4. Newbie Q: Return Error to Page?
      Hi, I have a web service method which will connect to a Access database, which look like below: public DataSet Search(string strSearch) {...
    5. newbie array inside a asp page
      Hello! Was thinking of having an array inside a asp page. I'm rather new to this. How do I begin. my asp page should work as follows: 1. One...
  3. #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" <me@nospam.com> wrote in message news:<uS3ZEPbVDHA.2328@TK2MSFTNGP12.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

  4. #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_now@o2.pl> wrote in message
    news:d71a96eb.0307290620.4da3279a@posting.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" <me@nospam.com> wrote in message
    news:<uS3ZEPbVDHA.2328@TK2MSFTNGP12.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

  5. #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" <me@nospam.com> wrote in message news:<#VdwR3eVDHA.1948@TK2MSFTNGP11.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_now@o2.pl> wrote in message
    > news:d71a96eb.0307290620.4da3279a@posting.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" <me@nospam.com> wrote in message
    > news:<uS3ZEPbVDHA.2328@TK2MSFTNGP12.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

Posting Permissions

  • You may not post new threads
  • You may 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