views:

3453

answers:

2

From what I've already read this appears to be impossible, but I wanted to see if anyone out there has a secret trick up their sleeve or at least a definitive "no".

Supposedly a master page is really just a control for a content page to use, not actually the "master" of a content page. If I wanted to go from one content page, to another content page with the same master page, I would just say

Response.Redirect("PageB.aspx");

But this would immediately cause a postback, flickering the page, which is the crappy pre-ajax way of doing things.

In this current project, I'm trying to see if I could figure out how to change the current content page of a ContentPlaceHolder in the master page asynchronously, when a button is clicked on the master page.

Is this possible, if so how?

+1  A: 

I don't know if you can between pages (.aspx) but it can definitely be done using UserControls.

ASP.Net pages each have their own URL so what you're trying to do is to go from one URL to another without any postback, that's just not how it's supposed to work.


Using user controls (.ascx):

Create a page that uses the MasterPage and use something like this in the content

<ajax:UpdatePanel ...>

    <ContentTemplate>

        <asp:PlaceHolder ...>

    </ContentTemplate>

</ajax:UpdatePanel>

Search for UpdatePanel and tweak its settings to do what you want, then learn how to swap user controls in a placeholder.

GoodEnough
As the first part of my answer mentions, I almost certain it's impossible using .aspx pages.
GoodEnough
A: 

No, you cannot because a master page is actually a control rendered on a particular aspx page, rather than actually containing the aspx page as it deceptively appears to be programmatically and in design view.

More Info:

You could however use a variety of other controls to simulate this effect. The asp:MultiView control is one example, each "page" could be made in a single view and placed in an update panel, thus allowing it to be switched asynchronously. Alternatively you could define each page in a separate user control and put those in an update panel, asynchronously switching the visible property on those controls as needed.

There are really a lot of different ways to achieve an effect similar to changing the master page's content placeholder.

Mark Rogers