dynamically change contentpage in MasterPage ???

C

Chris

hello.

How can I dynamically change a contentpage of the masterpage?

I have a listbox in the masterpage. Depending on the selected item i
want to show a different contentpage.

I try something like this (masterpage-code)

protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
switch (somethingtoTest)
{
case "1": ContentPlaceHolder1.Page = "Page1.aspx";
break;

case "2": ContentPlaceHolder1.Page = "Page2.aspx";
break;
break;
}
}

But the code is not accepted since "ContentPlaceHolder1.Page" is not
of type string.

But how then?

thank you
Chris
 
G

Gregory A. Beamer

Chris said:
hello.

How can I dynamically change a contentpage of the masterpage?

I have a listbox in the masterpage. Depending on the selected item i
want to show a different contentpage.

I try something like this (masterpage-code)

protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
switch (somethingtoTest)
{
case "1": ContentPlaceHolder1.Page = "Page1.aspx";
break;

case "2": ContentPlaceHolder1.Page = "Page2.aspx";
break;
break;
}
}

But the code is not accepted since "ContentPlaceHolder1.Page" is not
of type string.

But how then?

What a master page is, really, is a user control on a page. It does not
appear so due to the way it works, but that is what it is. As such, you
cannot get there from here. You can kludge up the page change, but you would
be better to add a postback to the dropdownlist and then have it redirect to
the correct page.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
C

Chris

What a master page is, really, is a user control on a page. It does not
appear so due to the way it works, but that is what it is. As such, you
cannot get there from here. You can kludge up the page change, but you would
be better to add a postback to the dropdownlist and then have it redirect to
the correct page.

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog:http://gregorybeamer.spaces.live.com

************************************************
|    Think outside the box!                        |
************************************************
Hello.

"but you would be better to add a postback to the dropdownlist and then have it redirect to
the correct page."

I don't understand. I'd say a master page consists of, amongst other
things, a contextplacehoder,
Contextplacehoder you use to display content of a page, hence the Page-
property of contextplacehoder.

how would you implement it then?
could you give me some sample code please?

thank you
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top