We are using Master pages and a multivew. We are using a Menu control to control the multivew with 3 views. Within each view there is another menu control and a contentplaceholder to load the pages we want to each view.
Once we load the pages into each view and click between them using the top menu control we lose the page we originally loaded even though we are setting the activeviewindex property in the master page conde behind. If we click the back button 2 times then
the page(s) from the other views appear.
How do we maintain state so when we click between the 3 views thru the menu control we are still able to view the 3 different pages.
I don't quite understand your problem. But based on my comprehension, I have made a sample. You can have a look. If the sample code don't resolve this problem. Can you provide your code without confidential part or business logic?
The only difference is that we don't put all three contentplaceholders in one aspx page. We have for example 10 pages that use ContentPlaceHolder1 and 5 that use ContentPlaceHolder2 and 6 that use ContentPlaceHolder3. What is happening is if we load
three different pages into the three differenct views then try switching between them only the last one loaded is displayed. If we switch between the 1st and 2nd pages loaded into their respective views then we get a blank screen except for the sub menus.
It's something with the contentplaceholders because the sub menus are defined explicity in the master page within each view and those display as expected. Only what is in the contentplaceholders is missing.
We are already doing that here in the Main Menu click event. Also, whenever I load a new page to display in a content placeholder the masterpage load event fired and the isPostBack flag is false. Some code snippets are below for reference. The submenus
items are built in code in the masterpage code behind on load.
<!-- Begin Main Menu --><tablewidth="100%"><tr><tdalign="left"><asp:MenuID="MenuMain"runat="server"BackColor="#00FFFF"DynamicHorizontalOffset="2"Font-Names="Verdana"Font-Size="Small"ForeColor="#000000"Orientation="Horizontal"StaticSubMenuIndent="10px"AccessKey="M"onmenuitemclick="MenuMain_MenuItemClick"><StaticSelectedStyleBackColor="Cornsilk"ForeColor="black"Font-Bold="True"BorderStyle="Inset"BorderWidth="0px"BorderColor="Red"/><StaticHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><StaticMenuItemStyleHorizontalPadding="10px"VerticalPadding="2px"/><DynamicMenuStyleBackColor="White"BorderStyle="Solid"BorderWidth="1px"/><DynamicHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><DynamicMenuItemStyleHorizontalPadding="5px"VerticalPadding="2px"/><Items><asp:MenuItemText="DIW"Value="0"/><asp:MenuItemText="OCS"Value="1"/><asp:MenuItemText="Safe Connect"Value="2"/></Items></asp:Menu></td></tr></table><!-- End Main Menu --><!-- Begin MultiView --><asp:MultiViewid="MultiView1"Runat="server"><asp:ViewID="vwDIW"runat="server"EnableViewState="true"><tableclass="ICMMainMenuTable"width="100%"><tr><tdalign="left"><asp:Menuid="mnuDIW"runat="server"BackColor="#e5e5e5"DynamicHorizontalOffset="2"Font-Names="Verdana"Font-Size="Small"ForeColor="#000000"Orientation="Horizontal"StaticSubMenuIndent="10px"AccessKey="M"><StaticSelectedStyleBackColor="White"ForeColor="black"Font-Bold="True"BorderStyle="Inset"BorderWidth="1px"BorderColor="Red"/><StaticHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><StaticMenuItemStyleHorizontalPadding="10px"VerticalPadding="2px"/><DynamicMenuStyleBackColor="White"BorderStyle="Solid"BorderWidth="1px"/><DynamicHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><DynamicMenuItemStyleHorizontalPadding="5px"VerticalPadding="2px"/></asp:Menu></td></tr></table><h3>DIW VIEW</h3><asp:ContentPlaceHolderid="ContentPlaceHolderDIW"runat="server"><!-- ! DIW CHILD ASPX PAGES HERE ! --></asp:ContentPlaceHolder></asp:View><asp:ViewID="vwOCS"runat="server"EnableViewState="true"><tableclass="ICMMainMenuTable"width="100%"><tr><tdalign="left"><asp:Menuid="mnuOCS"runat="server"BackColor="#e5e5e5"DynamicHorizontalOffset="2"Font-Names="Verdana"Font-Size="Small"ForeColor="#000000"Orientation="Horizontal"StaticSubMenuIndent="10px"AccessKey="M"><StaticSelectedStyleBackColor="White"ForeColor="black"Font-Bold="True"BorderStyle="Inset"BorderWidth="1px"BorderColor="Red"/><StaticHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><StaticMenuItemStyleHorizontalPadding="10px"VerticalPadding="2px"/><DynamicMenuStyleBackColor="White"BorderStyle="Solid"BorderWidth="1px"/><DynamicHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><DynamicMenuItemStyleHorizontalPadding="5px"VerticalPadding="2px"/></asp:Menu></td></tr></table><h3>OCS VIEW</h3><asp:ContentPlaceHolderid="ContentPlaceHolderOCS"runat="server"><!-- ! OCS CHILD ASPX PAGES HERE ! --></asp:ContentPlaceHolder></asp:View><asp:ViewID="vwSC"runat="server"EnableViewState="true"><tableclass="ICMMainMenuTable"width="100%"><tr><tdalign="left"><asp:Menuid="mnuSafeConnect"runat="server"BackColor="#e5e5e5"DynamicHorizontalOffset="2"Font-Names="Verdana"Font-Size="Small"ForeColor="#000000"Orientation="Horizontal"StaticSubMenuIndent="10px"AccessKey="M"><StaticSelectedStyleBackColor="White"ForeColor="black"Font-Bold="True"BorderStyle="Inset"BorderWidth="1px"BorderColor="Red"/><StaticHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><StaticMenuItemStyleHorizontalPadding="10px"VerticalPadding="2px"/><DynamicMenuStyleBackColor="White"BorderStyle="Solid"BorderWidth="1px"/><DynamicHoverStyleBackColor="#e5e5e5"ForeColor="Black"Font-Underline="True"/><DynamicMenuItemStyleHorizontalPadding="5px"VerticalPadding="2px"/></asp:Menu></td></tr></table><h3>Safe Connect VIEW</h3><asp:ContentPlaceHolderid="ContentPlaceHolderSC"runat="server"><!-- ! SafeCon CHILD ASPX PAGES HERE ! --></asp:ContentPlaceHolder></asp:View></asp:MultiView>
We are using Master pages and a multivew. We are using a Menu control to control the multivew with 3 views. Within each view there is another menu control and a contentplaceholder to load the pages we want to each view.
Once we load the pages into each view and click between them using the top menu control we lose the page we originally loaded even though we are setting the activeviewindex property in the master page conde behind. If we click the back button 2 times then
the page(s) from the other views appear.
How do we maintain state so when we click between the 3 views thru the menu control we are still able to view the 3 different pages.
Thx.
TGow
So what the question is why you click the back button 2 times then the page(s) from the other views appear?
I was only explaining that we are losing state and if we click the back button the missing page is loaded into the browser. The issue is why are we losing state when changing views.
TGow
Member
5 Points
6 Posts
Master Pages and Multiviews Display Page Problem
May 01, 2012 05:23 PM|LINK
We are using Master pages and a multivew. We are using a Menu control to control the multivew with 3 views. Within each view there is another menu control and a contentplaceholder to load the pages we want to each view.
Once we load the pages into each view and click between them using the top menu control we lose the page we originally loaded even though we are setting the activeviewindex property in the master page conde behind. If we click the back button 2 times then the page(s) from the other views appear.
How do we maintain state so when we click between the 3 views thru the menu control we are still able to view the 3 different pages.
Thx.
TGow
asp.netx.0lo...
Member
362 Points
71 Posts
Re: Master Pages and Multiviews Display Page Problem
May 02, 2012 07:04 AM|LINK
Hi TGow
I don't quite understand your problem. But based on my comprehension, I have made a sample. You can have a look. If the sample code don't resolve this problem. Can you provide your code without confidential part or business logic?
//MasterPage.master <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div> <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" onmenuitemclick="Menu1_MenuItemClick"> <Items> <asp:MenuItem Text="View1" Value="0"></asp:MenuItem> <asp:MenuItem Text="View2" Value="1"></asp:MenuItem> <asp:MenuItem Text="View3" Value="2"></asp:MenuItem> </Items> </asp:Menu> <br /> <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> <asp:View ID="View1" runat="server"> <asp:Menu ID="Menu2" runat="server"> <Items> <asp:MenuItem Text="V1Menu" Value="V1Menu"></asp:MenuItem> </Items> </asp:Menu> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </asp:View> <asp:View ID="View2" runat="server"> <asp:Menu ID="Menu3" runat="server"> <Items> <asp:MenuItem Text="V2Menu" Value="V2Menu"></asp:MenuItem> </Items> </asp:Menu> <asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server"> </asp:ContentPlaceHolder> </asp:View> <asp:View ID="View3" runat="server"> <asp:Menu ID="Menu4" runat="server"> <Items> <asp:MenuItem Text="V3Menu" Value="V3Menu"></asp:MenuItem> </Items> </asp:Menu> <asp:ContentPlaceHolder id="ContentPlaceHolder3" runat="server"> </asp:ContentPlaceHolder> </asp:View> </asp:MultiView> </div> </form> </body> </html> //MasterPage.master.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { MultiView1.ActiveViewIndex = Convert.ToInt32(Menu1.SelectedValue); } } //Default.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 1 </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"> 2 </asp:Content> <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server"> 3 </asp:Content>TGow
Member
5 Points
6 Posts
Re: Master Pages and Multiviews Display Page Problem
May 02, 2012 03:50 PM|LINK
The only difference is that we don't put all three contentplaceholders in one aspx page. We have for example 10 pages that use ContentPlaceHolder1 and 5 that use ContentPlaceHolder2 and 6 that use ContentPlaceHolder3. What is happening is if we load three different pages into the three differenct views then try switching between them only the last one loaded is displayed. If we switch between the 1st and 2nd pages loaded into their respective views then we get a blank screen except for the sub menus.
It's something with the contentplaceholders because the sub menus are defined explicity in the master page within each view and those display as expected. Only what is in the contentplaceholders is missing.
Thx.
asp.netx.0lo...
Member
362 Points
71 Posts
Re: Master Pages and Multiviews Display Page Problem
May 03, 2012 02:48 AM|LINK
Hi TGow
I finally found the problem you get. So you just need to reset the MultiView's property ActiveViewIndex when you change the view.
Here are the sample. You can follow up the post if you have anyting that need me to explain.
//test5.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="test5.aspx.cs" Inherits="test5" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"> 5 </asp:Content> <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server"> </asp:Content> //test5.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class test5 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { MultiView mlView; mlView = (MultiView)Master.FindControl("MultiView1"); if (mlView != null) { mlView.ActiveViewIndex = 1;//You need to change you want to for the displaying view. } } }Regards
asp.netx.0lover
TGow
Member
5 Points
6 Posts
Re: Master Pages and Multiviews Display Page Problem
May 03, 2012 04:36 PM|LINK
We are already doing that here in the Main Menu click event. Also, whenever I load a new page to display in a content placeholder the masterpage load event fired and the isPostBack flag is false. Some code snippets are below for reference. The submenus items are built in code in the masterpage code behind on load.
masterpage MenuMain_MenuItemClick:
asp.netx.0lo...
Member
362 Points
71 Posts
Re: Master Pages and Multiviews Display Page Problem
May 04, 2012 02:03 AM|LINK
So what the question is why you click the back button 2 times then the page(s) from the other views appear?
TGow
Member
5 Points
6 Posts
Re: Master Pages and Multiviews Display Page Problem
May 04, 2012 05:46 PM|LINK
I was only explaining that we are losing state and if we click the back button the missing page is loaded into the browser. The issue is why are we losing state when changing views.
Tom