Master Pages - loading of ContentPlaceHolder

Discussion in 'ASP .Net Web Services' started by John H W, Apr 27, 2005.

  1. John H W

    John H W Guest

    I currently use frames for a website. I plan on moving this site over to .NET
    now that the ISP is using ver 2 beta 2. I currently have the website working
    as below, but would like to get rid of the frame.

    My question is: can I use a master page(s) to do what I need to do.

    The page has the website's "banner" (name, logos, etc.) across the top, the
    site's menu (navigation) on the left side and a menu of "temporary" but long
    standing items (links) on the right. In the middle I want to have "news"
    items (linked to an article) when the page first comes up (or comes back to),
    but when you click on a menu page (currently pointing to a pdf, doc, html or
    asp page), a news item, or a long standing item, that item will appear in the
    middle - replacing the "news" items.

    It would appear that I could use asp:panel, programmeticly putting in the
    name of the page to load in the middle, but the books and other info I find
    only mention ascx pages. I have never used ascx pages and can find little to
    explain them.

    Question: Can I point the panel to a type of page other than an ascx page?

    How I thought of doing this is to use ?url="name of file" in recalling the
    default.aspx file with the "news" as the default. (menu has homepage which
    would reload default.aspx without the ?url. But I need to know is I have to
    change all my html pages.

    Thanks,
    John H W
    John H W, Apr 27, 2005
    #1
    1. Advertising

  2. John H W

    Brock Allen Guest

    > Question: Can I point the panel to a type of page other than an ascx
    > page?


    Panels don't point to anything. They are a control that can contain other
    controls. You can create any control and have it live "inside" the Panel
    -- just create the other control and add it to the Panel's Controls collection.
    If this doesn't get you going in the right direction, can you post a snippet
    of your current code so we can discuss those specifics?

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
    Brock Allen, Apr 27, 2005
    #2
    1. Advertising

  3. John H W

    John H W Guest

    I don't have any code yet, I am still in the planning stage. I need to be
    able to "load" into the center portion of the site various things which are
    now in html, asp, or pdf. I am now looking to having these come up into
    another window, but would rather then load into the center of the site.

    "Brock Allen" wrote:

    > > Question: Can I point the panel to a type of page other than an ascx
    > > page?

    >
    > Panels don't point to anything. They are a control that can contain other
    > controls. You can create any control and have it live "inside" the Panel
    > -- just create the other control and add it to the Panel's Controls collection.
    > If this doesn't get you going in the right direction, can you post a snippet
    > of your current code so we can discuss those specifics?
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >
    John H W, Apr 27, 2005
    #3
  4. John H W

    G Guest

    >> Panels don't point to anything. They are a control that can contain other
    >> controls. You can create any control and have it live "inside" the Panel
    >> -- just create the other control and add it to the Panel's Controls
    >> collection.
    >> If this doesn't get you going in the right direction, can you post a
    >> snippet
    >> of your current code so we can discuss those specifics?


    What about Server Side Includes, or, Iframes?

    G.
    G, Apr 28, 2005
    #4
  5. John H W

    Brock Allen Guest

    Well, MasterPages will accomplish this. You setup a .master file with your
    template, and somewhere in the .master where you want the individual page
    to fill in the details you place a <asp:ContentPlaceHolder> control. Then
    in the .aspx you indicate you want to use a .master (via <@% Page MasterPageFile="foo.master"%>)
    and then you only have a <asp:Content> control that fills in the details
    of what that page is to show. It's quite a nice feature/improvement in v2.0.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I don't have any code yet, I am still in the planning stage. I need
    > to be able to "load" into the center portion of the site various
    > things which are now in html, asp, or pdf. I am now looking to having
    > these come up into another window, but would rather then load into the
    > center of the site.
    >
    > "Brock Allen" wrote:
    >
    >>> Question: Can I point the panel to a type of page other than an
    >>> ascx page?
    >>>

    >> Panels don't point to anything. They are a control that can contain
    >> other controls. You can create any control and have it live "inside"
    >> the Panel -- just create the other control and add it to the Panel's
    >> Controls collection. If this doesn't get you going in the right
    >> direction, can you post a snippet of your current code so we can
    >> discuss those specifics?
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    Brock Allen, Apr 28, 2005
    #5
  6. John H W

    Brock Allen Guest

    > What about Server Side Includes, or, Iframes?

    Server side includes are supported, but the implementation is far less efficient
    than using a user control. They exist for backwards compatibility but should
    be used for new development.

    I suppose an IFRAME would work, but that causes additional requests to the
    server. A master page is served up in a single request.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
    Brock Allen, Apr 28, 2005
    #6
  7. John H W

    John H W Guest

    Brock:

    All the examples I have show that I have to have the contents of the
    ContentPlaceHolders in one .aspx page (which calls the master page). Is
    there a way to put the contents of different ContentPlaceHolders in different
    ..aspx pages? What I need to do is illustrated in sudocode:

    In default.aspx:
    <@% Page MasterPageFile="main.master"%>
    <script>
    Void Function Page_Load(object sender, EventArgs e)
    If default.aspx is called with a parameter then
    document.all.CenterFile.innerHTML = (load html formatted file named in
    parameter)
    else load the document.all.CenterFile.innerHTML from a default.html
    file
    End Function
    </script>
    ....
    <asp:Content runat="server" contentplaceholderID="CenterFile" />

    Would something like this work?

    Thanks,
    John H W

    "Brock Allen" wrote:

    > Well, MasterPages will accomplish this. You setup a .master file with your
    > template, and somewhere in the .master where you want the individual page
    > to fill in the details you place a <asp:ContentPlaceHolder> control. Then
    > in the .aspx you indicate you want to use a .master (via <@% Page MasterPageFile="foo.master"%>)
    > and then you only have a <asp:Content> control that fills in the details
    > of what that page is to show. It's quite a nice feature/improvement in v2.0.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > I don't have any code yet, I am still in the planning stage. I need
    > > to be able to "load" into the center portion of the site various
    > > things which are now in html, asp, or pdf. I am now looking to having
    > > these come up into another window, but would rather then load into the
    > > center of the site.
    > >
    > > "Brock Allen" wrote:
    > >
    > >>> Question: Can I point the panel to a type of page other than an
    > >>> ascx page?
    > >>>
    > >> Panels don't point to anything. They are a control that can contain
    > >> other controls. You can create any control and have it live "inside"
    > >> the Panel -- just create the other control and add it to the Panel's
    > >> Controls collection. If this doesn't get you going in the right
    > >> direction, can you post a snippet of your current code so we can
    > >> discuss those specifics?
    > >>
    > >> -Brock
    > >> DevelopMentor
    > >> http://staff.develop.com/ballen

    >
    >
    >
    >
    John H W, Apr 28, 2005
    #7
  8. John H W

    Brock Allen Guest

    Umm, I'm not really following what you're trying to do. If they want different
    "stuff" to go into the ContentPlaceHolder then why doesn't the user just
    browse to a different ASPX page? Each ASPX page that uses the same master
    will hiave its own content ("stuff") to show. I feel like I'm missing something,
    so let me know what it is :)

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Brock:
    >
    > All the examples I have show that I have to have the contents of the
    > ContentPlaceHolders in one .aspx page (which calls the master page).
    > Is there a way to put the contents of different ContentPlaceHolders in
    > different .aspx pages? What I need to do is illustrated in sudocode:
    >
    > In default.aspx:
    > <@% Page MasterPageFile="main.master"%>
    > <script>
    > Void Function Page_Load(object sender, EventArgs e)
    > If default.aspx is called with a parameter then
    > document.all.CenterFile.innerHTML = (load html formatted file named in
    > parameter)
    > else load the document.all.CenterFile.innerHTML from a
    > default.html
    > file
    > End Function
    > </script>
    > ...
    > <asp:Content runat="server" contentplaceholderID="CenterFile" />
    > Would something like this work?
    >
    > Thanks,
    > John H W
    > "Brock Allen" wrote:
    >
    >> Well, MasterPages will accomplish this. You setup a .master file with
    >> your template, and somewhere in the .master where you want the
    >> individual page to fill in the details you place a
    >> <asp:ContentPlaceHolder> control. Then in the .aspx you indicate you
    >> want to use a .master (via <@% Page MasterPageFile="foo.master"%>)
    >> and then you only have a <asp:Content> control that fills in the
    >> details of what that page is to show. It's quite a nice
    >> feature/improvement in v2.0.
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> I don't have any code yet, I am still in the planning stage. I need
    >>> to be able to "load" into the center portion of the site various
    >>> things which are now in html, asp, or pdf. I am now looking to
    >>> having these come up into another window, but would rather then load
    >>> into the center of the site.
    >>>
    >>> "Brock Allen" wrote:
    >>>
    >>>>> Question: Can I point the panel to a type of page other than an
    >>>>> ascx page?
    >>>>>
    >>>> Panels don't point to anything. They are a control that can contain
    >>>> other controls. You can create any control and have it live
    >>>> "inside" the Panel -- just create the other control and add it to
    >>>> the Panel's Controls collection. If this doesn't get you going in
    >>>> the right direction, can you post a snippet of your current code so
    >>>> we can discuss those specifics?
    >>>>
    >>>> -Brock
    >>>> DevelopMentor
    >>>> http://staff.develop.com/ballen
    Brock Allen, Apr 28, 2005
    #8
  9. John H W

    John H W Guest

    When a user selects a linked item (from the menu on the left hand page, a
    news store from the center section or the quick menu on the right side of the
    page ), we want that item to appear in the center, replacing the "News" item
    links that would be the default.

    Here is the layout of the master page (open window until you have three
    columns):

    L O G O a n d N A M E

    Menu Headline Quick Link
    item Headline Quick Link
    item Headline Quick Link

    Copyright Info

    We want any item selected under the menu, headline or quick link to display
    where the headline had been.

    The reason we don't want to have different .aspx pages calling the same
    ..master is that all of the menu and Quick links items would have be
    duplicated on the .aspx content pages. What I would prefer to do is just
    make a html formatted page (without having to put in the <html><body> tags,
    just the formatting tags and the content, then load it dynamically into the
    <asp:content> tag of the default.aspx page.

    John H W

    "Brock Allen" wrote:

    > Umm, I'm not really following what you're trying to do. If they want different
    > "stuff" to go into the ContentPlaceHolder then why doesn't the user just
    > browse to a different ASPX page? Each ASPX page that uses the same master
    > will hiave its own content ("stuff") to show. I feel like I'm missing something,
    > so let me know what it is :)
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > Brock:
    > >
    > > All the examples I have show that I have to have the contents of the
    > > ContentPlaceHolders in one .aspx page (which calls the master page).
    > > Is there a way to put the contents of different ContentPlaceHolders in
    > > different .aspx pages? What I need to do is illustrated in sudocode:
    > >
    > > In default.aspx:
    > > <@% Page MasterPageFile="main.master"%>
    > > <script>
    > > Void Function Page_Load(object sender, EventArgs e)
    > > If default.aspx is called with a parameter then
    > > document.all.CenterFile.innerHTML = (load html formatted file named in
    > > parameter)
    > > else load the document.all.CenterFile.innerHTML from a
    > > default.html
    > > file
    > > End Function
    > > </script>
    > > ...
    > > <asp:Content runat="server" contentplaceholderID="CenterFile" />
    > > Would something like this work?
    > >
    > > Thanks,
    > > John H W
    > > "Brock Allen" wrote:
    > >
    > >> Well, MasterPages will accomplish this. You setup a .master file with
    > >> your template, and somewhere in the .master where you want the
    > >> individual page to fill in the details you place a
    > >> <asp:ContentPlaceHolder> control. Then in the .aspx you indicate you
    > >> want to use a .master (via <@% Page MasterPageFile="foo.master"%>)
    > >> and then you only have a <asp:Content> control that fills in the
    > >> details of what that page is to show. It's quite a nice
    > >> feature/improvement in v2.0.
    > >>
    > >> -Brock
    > >> DevelopMentor
    > >> http://staff.develop.com/ballen
    > >>> I don't have any code yet, I am still in the planning stage. I need
    > >>> to be able to "load" into the center portion of the site various
    > >>> things which are now in html, asp, or pdf. I am now looking to
    > >>> having these come up into another window, but would rather then load
    > >>> into the center of the site.
    > >>>
    > >>> "Brock Allen" wrote:
    > >>>
    > >>>>> Question: Can I point the panel to a type of page other than an
    > >>>>> ascx page?
    > >>>>>
    > >>>> Panels don't point to anything. They are a control that can contain
    > >>>> other controls. You can create any control and have it live
    > >>>> "inside" the Panel -- just create the other control and add it to
    > >>>> the Panel's Controls collection. If this doesn't get you going in
    > >>>> the right direction, can you post a snippet of your current code so
    > >>>> we can discuss those specifics?
    > >>>>
    > >>>> -Brock
    > >>>> DevelopMentor
    > >>>> http://staff.develop.com/ballen

    >
    >
    >
    >
    John H W, Apr 28, 2005
    #9
  10. John H W

    Brock Allen Guest

    > The reason we don't want to have different .aspx pages calling the
    > same .master is that all of the menu and Quick links items would have
    > be duplicated on the .aspx content pages. What I would prefer to do
    > is just make a html formatted page (without having to put in the
    > <html><body> tags, just the formatting tags and the content, then load
    > it dynamically into the <asp:content> tag of the default.aspx page.


    Umm, the point of the master is so that you don't have to replicate the common
    layout or HTML across each of the pages. The master can also have common
    code that reacts to poastbacks and other events. You don't have to have just
    a single master page for the entire site. You can have some set of pages
    use one master and then antoher set of pages user a different one. One other
    thing is that Master pages can be nested, so a master can use another master,
    but that requires some planning when developing your website.

    If you don't think that master pages will do what you need, then you can
    always factor out the common HTML into a UserControl (which is an ASCX file).
    The ASCX file can either be included staticially on a page (or in a master)
    or it can be loaded dynamically via LoadControl. From what you described
    above, this might be the approach you want to take.

    Sorry I couldn't give you more definitive help.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
    Brock Allen, Apr 28, 2005
    #10
  11. John H W

    John H W Guest

    We are now back to one of my original questions - .ascx pages. I can find
    very little info on .ascx pages, how they are set up, etc. Do you know of a
    good source?

    Thanks for your help.

    John H W

    "Brock Allen" wrote:

    > > The reason we don't want to have different .aspx pages calling the
    > > same .master is that all of the menu and Quick links items would have
    > > be duplicated on the .aspx content pages. What I would prefer to do
    > > is just make a html formatted page (without having to put in the
    > > <html><body> tags, just the formatting tags and the content, then load
    > > it dynamically into the <asp:content> tag of the default.aspx page.

    >
    > Umm, the point of the master is so that you don't have to replicate the common
    > layout or HTML across each of the pages. The master can also have common
    > code that reacts to poastbacks and other events. You don't have to have just
    > a single master page for the entire site. You can have some set of pages
    > use one master and then antoher set of pages user a different one. One other
    > thing is that Master pages can be nested, so a master can use another master,
    > but that requires some planning when developing your website.
    >
    > If you don't think that master pages will do what you need, then you can
    > always factor out the common HTML into a UserControl (which is an ASCX file).
    > The ASCX file can either be included staticially on a page (or in a master)
    > or it can be loaded dynamically via LoadControl. From what you described
    > above, this might be the approach you want to take.
    >
    > Sorry I couldn't give you more definitive help.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >
    >
    John H W, Apr 28, 2005
    #11
  12. John H W

    Brock Allen Guest

    MSDN has tons of documentation and articles:

    http://msdn.microsoft.com/library/d...ml/cpconcreatingpageletcontrol.asp?frame=true

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > We are now back to one of my original questions - .ascx pages. I can
    > find very little info on .ascx pages, how they are set up, etc. Do
    > you know of a good source?
    >
    > Thanks for your help.
    >
    > John H W
    >
    > "Brock Allen" wrote:
    >
    >>> The reason we don't want to have different .aspx pages calling the
    >>> same .master is that all of the menu and Quick links items would
    >>> have be duplicated on the .aspx content pages. What I would prefer
    >>> to do is just make a html formatted page (without having to put in
    >>> the <html><body> tags, just the formatting tags and the content,
    >>> then load it dynamically into the <asp:content> tag of the
    >>> default.aspx page.
    >>>

    >> Umm, the point of the master is so that you don't have to replicate
    >> the common layout or HTML across each of the pages. The master can
    >> also have common code that reacts to poastbacks and other events. You
    >> don't have to have just a single master page for the entire site. You
    >> can have some set of pages use one master and then antoher set of
    >> pages user a different one. One other thing is that Master pages can
    >> be nested, so a master can use another master, but that requires some
    >> planning when developing your website.
    >>
    >> If you don't think that master pages will do what you need, then you
    >> can always factor out the common HTML into a UserControl (which is an
    >> ASCX file). The ASCX file can either be included staticially on a
    >> page (or in a master) or it can be loaded dynamically via
    >> LoadControl. From what you described above, this might be the
    >> approach you want to take.
    >>
    >> Sorry I couldn't give you more definitive help.
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    Brock Allen, Apr 28, 2005
    #12
  13. John H W

    John H W Guest

    Brock, thanks for all your help in pointing my thinking in the proper
    direction.

    John H W

    "Brock Allen" wrote:

    > MSDN has tons of documentation and articles:
    >
    > http://msdn.microsoft.com/library/d...ml/cpconcreatingpageletcontrol.asp?frame=true
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > We are now back to one of my original questions - .ascx pages. I can
    > > find very little info on .ascx pages, how they are set up, etc. Do
    > > you know of a good source?
    > >
    > > Thanks for your help.
    > >
    > > John H W
    > >
    > > "Brock Allen" wrote:
    > >
    > >>> The reason we don't want to have different .aspx pages calling the
    > >>> same .master is that all of the menu and Quick links items would
    > >>> have be duplicated on the .aspx content pages. What I would prefer
    > >>> to do is just make a html formatted page (without having to put in
    > >>> the <html><body> tags, just the formatting tags and the content,
    > >>> then load it dynamically into the <asp:content> tag of the
    > >>> default.aspx page.
    > >>>
    > >> Umm, the point of the master is so that you don't have to replicate
    > >> the common layout or HTML across each of the pages. The master can
    > >> also have common code that reacts to poastbacks and other events. You
    > >> don't have to have just a single master page for the entire site. You
    > >> can have some set of pages use one master and then antoher set of
    > >> pages user a different one. One other thing is that Master pages can
    > >> be nested, so a master can use another master, but that requires some
    > >> planning when developing your website.
    > >>
    > >> If you don't think that master pages will do what you need, then you
    > >> can always factor out the common HTML into a UserControl (which is an
    > >> ASCX file). The ASCX file can either be included staticially on a
    > >> page (or in a master) or it can be loaded dynamically via
    > >> LoadControl. From what you described above, this might be the
    > >> approach you want to take.
    > >>
    > >> Sorry I couldn't give you more definitive help.
    > >>
    > >> -Brock
    > >> DevelopMentor
    > >> http://staff.develop.com/ballen

    >
    >
    >
    >
    John H W, Apr 29, 2005
    #13
    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. Billy Cormic

    master pages contentplaceholder

    Billy Cormic, Aug 31, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    571
    Billy Cormic
    Sep 1, 2004
  2. Greg
    Replies:
    4
    Views:
    14,880
    dassyms
    Apr 17, 2006
  3. Replies:
    1
    Views:
    3,198
    PeterKellner
    May 16, 2006
  4. Replies:
    5
    Views:
    4,173
    clintonG
    Jun 2, 2006
  5. Greg
    Replies:
    1
    Views:
    203
    Ward Bekker
    Mar 23, 2006
Loading...

Share This Page