dynamically change contentpage in MasterPage ???

  • Thread starter Thread starter Chris
  • Start date Start date
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
 
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! |
************************************************
 
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 redirectto
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
 
Back
Top