2 Questions about using AJAX with Master Page

Discussion in 'ASP .Net' started by Dani, May 25, 2008.

  1. Dani

    Dani Guest

    Hi,

    Trying to create a master page that holds a menu, and the menu switches
    between pages in the site. 2 problem arrosed:

    a. When I navigate from page to page (all AJAX Web Forms, with the Master
    pages as their master...) the entire page is refreshed - also the menu which
    belongs to the master, how can I fix it - so only the inside content will be
    refreshed ?

    b. When I try to put an AJAX enabled control that I've created inside one of
    the page, I get an error - either I don't have a Script manager (which is
    located on the master page btw) or - if I add a script manager - that I have
    1 too many...
    so - I damned if I do and damned if I don't...

    how can I create a control that only updates itself (it's a bunch of
    comboboxes depends on each other) and put it in that kind of web page ?

    Thanks,

    Dani
    Dani, May 25, 2008
    #1
    1. Advertising

  2. Dani

    Dani Guest

    Thanks for the quick reply.
    Is there a "Good" way to write a site that uses a master page and doesn't
    make the menu reload every time ?
    Dani


    "Mark Rae [MVP]" wrote:

    > "Dani" <> wrote in message
    > news:...
    >
    > > Trying to create a master page that holds a menu, and the menu switches
    > > between pages in the site. 2 problem arrose:
    > >
    > > a. When I navigate from page to page (all AJAX Web Forms, with the Master
    > > pages as their master...) the entire page is refreshed - also the menu
    > > which
    > > belongs to the master, how can I fix it - so only the inside content will
    > > be
    > > refreshed ?

    >
    > I'm afraid you've made the "classic" newbie misconception about MasterPages
    > that they are somehow the ASP.NET equivalent of framesets. They are nothing
    > at all like framesets. In fact, a MasterPage is nothing more than a special
    > kind of UserControl. When a content page is requested, it loads its
    > MasterPage control which it merges with its own markup and creates a single
    > page. This happens every time. That's how MasterPages work...
    >
    > > b. When I try to put an AJAX enabled control that I've created inside one
    > > of
    > > the page, I get an error - either I don't have a Script manager (which is
    > > located on the master page btw) or - if I add a script manager - that I
    > > have
    > > 1 too many...
    > > so - I damned if I do and damned if I don't...

    >
    > http://aspalliance.com/1285_Tip_and_Tricks_ASPNET_20_AJAX_10_Extensions_and_Master_Pages.5
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    Dani, May 25, 2008
    #2
    1. Advertising

  3. Dani

    clintonG Guest

    I haven't tried myself but wonder if the update panel can be loaded in the
    content page. I presume that would produce desired results. Furthermore,
    when the Menu control is in the Master there will likely be some additional
    coding required.

    Technically speaking, it should also be noted Mark is incorrect because the
    MasterPage is --not-- a User Control per se but a unique type which
    functions similar to a User Control and then only when the page is compiled.

    Most people do not want to explain in detail. Since the typed Master
    functions similar to a User Control it has become common to describe it as
    such to help people understand that Master Pages do not function like HTML
    Framesets.

    I would go to http://odetocode.com/ as K. Scott Allen has done a lot of work
    describing MasterPages but that was before AJAX so I don't know if he's done
    anything in the context of using AJAX. Going to the forums at
    http://asp.net/ would be helpful too.



    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Dani" <> wrote in message
    > news:...
    >
    > [top-posting corrected]
    >
    >>>> a. When I navigate from page to page (all AJAX Web Forms, with the
    >>>> Master
    >>>> pages as their master...) the entire page is refreshed - also the menu
    >>>> which belongs to the master, how can I fix it - so only the inside
    >>>> content will
    >>>> be refreshed ?
    >>>
    >>> I'm afraid you've made the "classic" newbie misconception about
    >>> MasterPages
    >>> that they are somehow the ASP.NET equivalent of framesets. They are
    >>> nothing
    >>> at all like framesets. In fact, a MasterPage is nothing more than a
    >>> special
    >>> kind of UserControl. When a content page is requested, it loads its
    >>> MasterPage control which it merges with its own markup and creates a
    >>> single
    >>> page. This happens every time. That's how MasterPages work...

    >>
    >> Is there a "Good" way to write a site that uses a master page and doesn't
    >> make the menu reload every time ?

    >
    > I've obviously not explained clearly enough - when I said "That's how
    > MasterPages work", that's what I meant...
    >
    > Specifically, a MasterPage is just a UserControl like any other
    > UserControl. When you add a UserControl to a page, it gets loaded every
    > time the page loads. That's how UserControls work. A MasterPage is a
    > UserControl, so it gets loaded every time the page loads. That's how
    > MasterPages work, because MasterPages are UserControls...
    >
    > MasterPages are't frames. That's not how MasterPages work...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    clintonG, May 25, 2008
    #3
  4. Dani

    clintonG Guest

    So you should have no problem at all providing a URL from MSDN2 that
    definitively and without question documents the typed Master as a User
    Control.

    <%= Clinton Gallagher


    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "clintonG" <> wrote in message
    > news:%23$...
    >
    >> Technically speaking, it should also be noted Mark is incorrect because
    >> the MasterPage is --not-- a User Control per se but a unique type which
    >> functions similar to a User Control and then only when the page is
    >> compiled.

    >
    > A MasterPage absolutely is a UserControl.
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    clintonG, May 26, 2008
    #4
  5. re:
    !> So you should have no problem at all providing a URL from MSDN2 that
    !> definitively and without question documents the typed Master as a User Control.

    clintonG :

    Here's 3 URLs which list MasterPage Properties, Members and Methods :

    http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_properties.aspx
    http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_members.aspx
    http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_methods.aspx

    Notice that every single Property, Member and Method used/owned by
    a MasterPage inherits from either Control, UserControl or TemplateControl.

    Since the UserControl, Page and MasterPage classes all are subclasses of System.Web.UI.

    See :
    http://quickstarts.asp.net/QuickStartv20/util/classbrowser.aspx?namespace=System.Web.UI

    When an HTTP request is made for a page at run time, the master page and content
    pages are combined into a single class with the same name as the content pages.

    The *resulting* compiled, merged class derives from the Page class.

    The MasterPage class derives (inherits, actually) from Control,
    and is last in a chain which includes Control, TemplateControl and UserControl:

    Here's the inheritance hierarchy for the MasterPage class :

    System..::.Object
    System.Web.UI..::.Control
    System.Web.UI..::.TemplateControl
    System.Web.UI..::.UserControl
    System.Web.UI..::.MasterPage

    The master page is initialized as the top control in a page's control hierarchy by
    clearing the page's Controls array and adding the master page to the Control collection.

    MasterPage inherits from UserControl...so it's a form of UserControl.
    If it looks like a duck and quacks like a duck and inherits from a duck...it's a duck.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "clintonG" <> wrote in message news:...
    > So you should have no problem at all providing a URL from MSDN2 that definitively and without question documents the
    > typed Master as a User Control.
    >
    > <%= Clinton Gallagher
    >
    >
    > "Mark Rae [MVP]" <> wrote in message news:%...
    >> "clintonG" <> wrote in message news:%23$...
    >>
    >>> Technically speaking, it should also be noted Mark is incorrect because the MasterPage is --not-- a User Control per
    >>> se but a unique type which functions similar to a User Control and then only when the page is compiled.

    >>
    >> A MasterPage absolutely is a UserControl.
    >>
    >>
    >> --
    >> Mark Rae
    >> ASP.NET MVP
    >> http://www.markrae.net

    >
    Juan T. Llibre, May 26, 2008
    #5
  6. Dani

    clintonG Guest

    Dani you need to scroll down to 5/20 and get into the discussion: Do you
    prefer Master Page or User Controls?

    Mark --and others-- usually cite this document [1] but if you went to school
    and learned to read like I did nowhere does the documentation definitively
    state the Master --IS A-- User Control but MSDN documentation does --imply--
    the Master is --LIKE A-- User Control because it supports the same
    directives are inherited so to speak. Furthermore, it may be a stretch to
    say the Master is --A TYPE OF-- User Control as usually stated but again,
    the documentation does not say this. It is all implied leaving the matter up
    for speculation.

    Now speaking of "inheritance" get this...

    The User Control can also be understood as a Mulatto Control: like being
    born when one parent is a Negro and the other Caucasian then what race are
    you?
    I'll actually use this analogy but prefer a "safer" analogy which really
    puts the matter of implication into perspective in the 5/20 discussion so
    don't miss it, the fur may start to fly ;-)

    <%= Clinton Gallagher

    [1] http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage.aspx
    [2] http://en.wikipedia.org/wiki/Mulatto


    "Dani" <> wrote in message
    news:...
    > Thanks for the quick reply.
    > Is there a "Good" way to write a site that uses a master page and doesn't
    > make the menu reload every time ?
    > Dani
    >
    >
    > "Mark Rae [MVP]" wrote:
    >
    >> "Dani" <> wrote in message
    >> news:...
    >>
    >> > Trying to create a master page that holds a menu, and the menu switches
    >> > between pages in the site. 2 problem arrose:
    >> >
    >> > a. When I navigate from page to page (all AJAX Web Forms, with the
    >> > Master
    >> > pages as their master...) the entire page is refreshed - also the menu
    >> > which
    >> > belongs to the master, how can I fix it - so only the inside content
    >> > will
    >> > be
    >> > refreshed ?

    >>
    >> I'm afraid you've made the "classic" newbie misconception about
    >> MasterPages
    >> that they are somehow the ASP.NET equivalent of framesets. They are
    >> nothing
    >> at all like framesets. In fact, a MasterPage is nothing more than a
    >> special
    >> kind of UserControl. When a content page is requested, it loads its
    >> MasterPage control which it merges with its own markup and creates a
    >> single
    >> page. This happens every time. That's how MasterPages work...
    >>
    >> > b. When I try to put an AJAX enabled control that I've created inside
    >> > one
    >> > of
    >> > the page, I get an error - either I don't have a Script manager (which
    >> > is
    >> > located on the master page btw) or - if I add a script manager - that I
    >> > have
    >> > 1 too many...
    >> > so - I damned if I do and damned if I don't...

    >>
    >> http://aspalliance.com/1285_Tip_and_Tricks_ASPNET_20_AJAX_10_Extensions_and_Master_Pages.5
    >>
    >>
    >> --
    >> Mark Rae
    >> ASP.NET MVP
    >> http://www.markrae.net
    >>
    >>
    clintonG, May 26, 2008
    #6
  7. You say that all so well but tell me then please; does MasterPage
    inherit --from-- User Control as you said or --through-- User Control, and
    if strictly from User Control as you imply why then is the MasterPage not
    injected --into-- the control tree the way a User Control is but the
    compiler "redims" the control tree so it can wrap the MasterPage around it?


    Can you quack that?






    "Juan T. Llibre" <> wrote in message
    news:%...
    > re:
    > !> So you should have no problem at all providing a URL from MSDN2 that
    > !> definitively and without question documents the typed Master as a User
    > Control.
    >
    > clintonG :
    >
    > Here's 3 URLs which list MasterPage Properties, Members and Methods :
    >
    > http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_properties.aspx
    > http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_members.aspx
    > http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_methods.aspx
    >
    > Notice that every single Property, Member and Method used/owned by
    > a MasterPage inherits from either Control, UserControl or TemplateControl.
    >
    > Since the UserControl, Page and MasterPage classes all are subclasses of
    > System.Web.UI.
    >
    > See :
    > http://quickstarts.asp.net/QuickStartv20/util/classbrowser.aspx?namespace=System.Web.UI
    >
    > When an HTTP request is made for a page at run time, the master page and
    > content
    > pages are combined into a single class with the same name as the content
    > pages.
    >
    > The *resulting* compiled, merged class derives from the Page class.
    >
    > The MasterPage class derives (inherits, actually) from Control,
    > and is last in a chain which includes Control, TemplateControl and
    > UserControl:
    >
    > Here's the inheritance hierarchy for the MasterPage class :
    >
    > System..::.Object
    > System.Web.UI..::.Control
    > System.Web.UI..::.TemplateControl
    > System.Web.UI..::.UserControl
    > System.Web.UI..::.MasterPage
    >
    > The master page is initialized as the top control in a page's control
    > hierarchy by
    > clearing the page's Controls array and adding the master page to the
    > Control collection.
    >
    > MasterPage inherits from UserControl...so it's a form of UserControl.
    > If it looks like a duck and quacks like a duck and inherits from a
    > duck...it's a duck.
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ======================================
    > "clintonG" <> wrote in message
    > news:...
    >> So you should have no problem at all providing a URL from MSDN2 that
    >> definitively and without question documents the typed Master as a User
    >> Control.
    >>
    >> <%= Clinton Gallagher
    >>
    >>
    >> "Mark Rae [MVP]" <> wrote in message
    >> news:%...
    >>> "clintonG" <> wrote in message
    >>> news:%23$...
    >>>
    >>>> Technically speaking, it should also be noted Mark is incorrect because
    >>>> the MasterPage is --not-- a User Control per se but a unique type which
    >>>> functions similar to a User Control and then only when the page is
    >>>> compiled.
    >>>
    >>> A MasterPage absolutely is a UserControl.
    >>>
    >>>
    >>> --
    >>> Mark Rae
    >>> ASP.NET MVP
    >>> http://www.markrae.net

    >>

    >
    >
    Microsoft Victim, May 26, 2008
    #7
  8. re:
    !> You say that all so well but tell me then please; does MasterPage
    !> inherit --from-- User Control as you said or --through-- User Control

    *From* UserControl.

    re:
    !> why then is the MasterPage not injected --into-- the control tree the way a User Control
    !> is but the compiler "redims" the control tree so it can wrap the MasterPage around it?

    This was already explained by :
    !>> The master page is initialized as the top control in a page's control hierarchy by
    !>> clearing the page's Controls array and adding the master page to the Control collection.

    After that occurs, the MasterPage becomes the top control.

    A MasterPage is a template and merging container UserControl which can host other controls.

    It inherits directly from UserControl, which in turn inherits from TemplateControl.

    In order for a MasterPage to be able to host *all* the other controls a user might
    add, as the page's control container, it must be the top control in the page.





    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Microsoft Victim" <> wrote in message news:%...
    > You say that all so well but tell me then please; does MasterPage inherit --from-- User Control as you said
    > or --through-- User Control, and if strictly from User Control as you imply why then is the MasterPage not
    > injected --into-- the control tree the way a User Control is but the compiler "redims" the control tree so it can wrap
    > the MasterPage around it?
    >
    >
    > Can you quack that?
    >
    >
    >
    >
    >
    >
    > "Juan T. Llibre" <> wrote in message news:%...
    >> re:
    >> !> So you should have no problem at all providing a URL from MSDN2 that
    >> !> definitively and without question documents the typed Master as a User Control.
    >>
    >> clintonG :
    >>
    >> Here's 3 URLs which list MasterPage Properties, Members and Methods :
    >>
    >> http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_properties.aspx
    >> http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_members.aspx
    >> http://msdn.microsoft.com/en-us/library/system.web.ui.masterpage_methods.aspx
    >>
    >> Notice that every single Property, Member and Method used/owned by
    >> a MasterPage inherits from either Control, UserControl or TemplateControl.
    >>
    >> Since the UserControl, Page and MasterPage classes all are subclasses of System.Web.UI.
    >>
    >> See :
    >> http://quickstarts.asp.net/QuickStartv20/util/classbrowser.aspx?namespace=System.Web.UI
    >>
    >> When an HTTP request is made for a page at run time, the master page and content
    >> pages are combined into a single class with the same name as the content pages.
    >>
    >> The *resulting* compiled, merged class derives from the Page class.
    >>
    >> The MasterPage class derives (inherits, actually) from Control,
    >> and is last in a chain which includes Control, TemplateControl and UserControl:
    >>
    >> Here's the inheritance hierarchy for the MasterPage class :
    >>
    >> System..::.Object
    >> System.Web.UI..::.Control
    >> System.Web.UI..::.TemplateControl
    >> System.Web.UI..::.UserControl
    >> System.Web.UI..::.MasterPage
    >>
    >> The master page is initialized as the top control in a page's control hierarchy by
    >> clearing the page's Controls array and adding the master page to the Control collection.
    >>
    >> MasterPage inherits from UserControl...so it's a form of UserControl.
    >> If it looks like a duck and quacks like a duck and inherits from a duck...it's a duck.
    >>
    >>
    >>
    >>
    >> Juan T. Llibre, asp.net MVP
    >> asp.net faq : http://asp.net.do/faq/
    >> foros de asp.net, en español : http://asp.net.do/foros/
    >> ======================================
    >> "clintonG" <> wrote in message news:...
    >>> So you should have no problem at all providing a URL from MSDN2 that definitively and without question documents the
    >>> typed Master as a User Control.
    >>>
    >>> <%= Clinton Gallagher
    >>>
    >>>
    >>> "Mark Rae [MVP]" <> wrote in message news:%...
    >>>> "clintonG" <> wrote in message news:%23$...
    >>>>
    >>>>> Technically speaking, it should also be noted Mark is incorrect because the MasterPage is --not-- a User Control
    >>>>> per se but a unique type which functions similar to a User Control and then only when the page is compiled.
    >>>>
    >>>> A MasterPage absolutely is a UserControl.
    >>>>
    >>>>
    >>>> --
    >>>> Mark Rae
    >>>> ASP.NET MVP
    >>>> http://www.markrae.net
    >>>

    >>
    >>

    >
    Juan T. Llibre, May 27, 2008
    #8
    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:
    982
    William Brogden
    Aug 5, 2004
  2. Replies:
    1
    Views:
    3,179
    PeterKellner
    May 16, 2006
  3. Zeba
    Replies:
    1
    Views:
    471
    Mark Rae
    Feb 22, 2007
  4. Nathan Sokalski
    Replies:
    25
    Views:
    1,390
    Nathan Sokalski
    Mar 4, 2010
  5. SerpentKiss2010
    Replies:
    0
    Views:
    2,453
    SerpentKiss2010
    Apr 6, 2011
Loading...

Share This Page