Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dynamically change contentpage in MasterPage ???

Reply
Thread Tools

dynamically change contentpage in MasterPage ???

 
 
Chris
Guest
Posts: n/a
 
      02-21-2010
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
 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      02-21-2010


"Chris" <> wrote in message
news:42fbe2b9-5259-42a0-9418-...
> 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! |
************************************************

 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      02-21-2010
On Feb 21, 3:34*am, "Gregory A. Beamer"
<NoSpamMgbwo...@comcast.netNoSpamM> wrote:
> "Chris" <cmr...@gmail.com> wrote in message
>
> news:42fbe2b9-5259-42a0-9418-...
>
>
>
> > 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! * * * * * * * * * * * *|
> ************************************************


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling MasterPage Subroutines from a ContentPage jeffmagill@gmail.com ASP .Net 7 01-11-2013 03:54 AM
Finding Value of Dynamic Control in MasterPage/ContentPage System dawg1998 ASP .Net 2 05-31-2010 06:19 AM
Finding Value of Dynamic Control in MasterPage/ContentPage System =?Utf-8?B?ZGF3ZzE5OTg=?= ASP .Net 0 03-15-2006 05:26 PM
MasterPage Method Invocation from ContentPage User ASP .Net 9 12-19-2005 11:20 AM
Change Webcontrols from a Contentpage in the Masterpage phil1bruening@web.de ASP .Net 1 11-22-2005 03:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57