Content Not Rendering in Master Page

Discussion in 'ASP .Net' started by =?Utf-8?B?R1RC?=, Jul 25, 2006.

  1. Hi,

    I have a master page, with a single content placeholder.

    I create a content page for it with some appropriate content. At this point
    everything is working fine.

    However I need to change the type of my content page to use my own BasePage
    class that contains a lot of code for handling resources and web service
    calls. The PageBase class inherits from System.Web.UI.Page.

    This a cutdown version with all my extra code removed.

    public class PageBase: System.Web.UI.Page
    {
    protected override void OnInit(EventArgs e)
    {
    if (this.Master != null)
    {
    //prevents ASP.Net from shoving ctl001 in front of all my
    tag ID's.
    this.Master.ID = "demo";
    }
    base.OnInit(e);
    }
    }

    So my content page code-behind looks like this:

    public partial class contentPage: PageBase
    {
    ....
    }

    Everything compiles fine.

    When I load the content page and debug, all my code runs. In the browser the
    title is set appropriately and other data-driven changes to the master page
    are visible. However the content in the contentplaceholder does not render.

    What happens when I inherit from System.Web.UI.Page that causes the content
    page to no longer render?

    Any thoughts?

    GTB
     
    =?Utf-8?B?R1RC?=, Jul 25, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?R1RC?=

    Craig Guest

    Hi,

    I have the same exact problem.
    I figured out that it is cause because they way we're accesing the master
    page.
    I think that is not the correct way, though, I don't know what's the right
    way either.
    I'm gonna investigate more on this and post my findings.

    Regards,



    "GTB" <> wrote in message
    news:...
    > Hi,
    >
    > I have a master page, with a single content placeholder.
    >
    > I create a content page for it with some appropriate content. At this
    > point
    > everything is working fine.
    >
    > However I need to change the type of my content page to use my own
    > BasePage
    > class that contains a lot of code for handling resources and web service
    > calls. The PageBase class inherits from System.Web.UI.Page.
    >
    > This a cutdown version with all my extra code removed.
    >
    > public class PageBase: System.Web.UI.Page
    > {
    > protected override void OnInit(EventArgs e)
    > {
    > if (this.Master != null)
    > {
    > //prevents ASP.Net from shoving ctl001 in front of all my
    > tag ID's.
    > this.Master.ID = "demo";
    > }
    > base.OnInit(e);
    > }
    > }
    >
    > So my content page code-behind looks like this:
    >
    > public partial class contentPage: PageBase
    > {
    > ...
    > }
    >
    > Everything compiles fine.
    >
    > When I load the content page and debug, all my code runs. In the browser
    > the
    > title is set appropriately and other data-driven changes to the master
    > page
    > are visible. However the content in the contentplaceholder does not
    > render.
    >
    > What happens when I inherit from System.Web.UI.Page that causes the
    > content
    > page to no longer render?
    >
    > Any thoughts?
    >
    > GTB
     
    Craig, Sep 27, 2006
    #2
    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. Doug McCann
    Replies:
    1
    Views:
    1,079
    William Brogden
    Aug 5, 2004
  2. Replies:
    0
    Views:
    740
  3. Laith Zraikat
    Replies:
    3
    Views:
    1,237
    Walter Wang [MSFT]
    Jul 6, 2006
  4. Rolf Welskes
    Replies:
    7
    Views:
    986
    Steven Cheng[MSFT]
    Aug 22, 2006
  5. John
    Replies:
    2
    Views:
    924
Loading...

Share This Page