2
Answers

Master Page not displaying Aspx Page within a contentplaceholder in a Multiview control

tom gow

tom gow

12y
3.4k
1

Using masterpages, multiview and menu controls.   A contentplaceholder is nested in each view.   When we load aspx pages into each view and try to switch between them we lose view or state of the others and can only see the last page loaded in its view.

Code snippets of master page aspx and code behind.

 

>>>MultiView ASPX Page:<<<
<!-- Begin Main Menu -->
  <table width="100%">
   <tr>
    <td align="left">     
     <asp:Menu ID="MenuMain"
          runat="server"
          BackColor="#00FFFF"
          DynamicHorizontalOffset="2"
          Font-Names="Verdana"
          Font-Size="Small"
          ForeColor="#000000"
          Orientation="Horizontal"               
          StaticSubMenuIndent="10px"
          AccessKey="M"
          onmenuitemclick="MenuMain_MenuItemClick">

      <StaticSelectedStyle BackColor="Cornsilk" ForeColor="black" Font-Bold="True" BorderStyle="Inset" BorderWidth="0px" BorderColor="Red" />              
      <StaticHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
      <StaticMenuItemStyle HorizontalPadding="10px" VerticalPadding="2px"/>       
   
      <DynamicMenuStyle BackColor="White" BorderStyle="Solid" BorderWidth="1px"/>
      <DynamicHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
      <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
    <Items>
      <asp:MenuItem Text="DIW" Value="0"/>
      <asp:MenuItem Text="OCS" Value="1"/>
      <asp:MenuItem Text="Safe Connect" Value="2"/>
    </Items>   
    </asp:Menu>
    </td>       
   </tr>
  </table>       
<!-- End Main Menu -->
<!-- Begin MultiView --> 
  <asp:MultiView
    id="MultiView1"
    Runat="server">
    <asp:View ID="vwDIW" runat="server" EnableViewState="true" EnableTheming="False">
    <table class="ICMMainMenuTable" width="100%">
      <tr>
      <td align="left">
        <asp:Menu
        id="mnuDIW"
        runat="server"
        BackColor="#e5e5e5"
        DynamicHorizontalOffset="2"
        Font-Names="Verdana"
        Font-Size="Small"
        ForeColor="#000000"
        Orientation="Horizontal"               
        StaticSubMenuIndent="10px"
        AccessKey="M">

      <StaticSelectedStyle BackColor="White" ForeColor="black" Font-Bold="True" BorderStyle="Inset" BorderWidth="1px" BorderColor="Red" />              
      <StaticHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
      <StaticMenuItemStyle HorizontalPadding="10px" VerticalPadding="2px"/>       
   
      <DynamicMenuStyle BackColor="White" BorderStyle="Solid" BorderWidth="1px"/>
      <DynamicHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
      <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
      </asp:Menu>
      </td>       
      </tr>
    </table>
    <h3>DIW VIEW</h3>       
       <asp:ContentPlaceHolder  id="ContentPlaceHolderDIW" runat="server">
        <!-- ! DIW CHILD PAGES CODE GOES HERE ! -->
      </asp:ContentPlaceHolder>
  </asp:View>
               
    <asp:View ID="vwOCS" runat="server" EnableViewState="true" EnableTheming="False">
    <table class="ICMMainMenuTable" width="100%">
      <tr>
      <td align="left">
        <asp:Menu
        id="mnuOCS"
          runat="server"
          BackColor="#e5e5e5"
          DynamicHorizontalOffset="2"
          Font-Names="Verdana"
          Font-Size="Small"
          ForeColor="#000000"
          Orientation="Horizontal"               
          StaticSubMenuIndent="10px"
          AccessKey="M">

        <StaticSelectedStyle BackColor="White" ForeColor="black" Font-Bold="True" BorderStyle="Inset" BorderWidth="1px" BorderColor="Red" />              
        <StaticHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
        <StaticMenuItemStyle HorizontalPadding="10px" VerticalPadding="2px"/>       
   
        <DynamicMenuStyle BackColor="White" BorderStyle="Solid" BorderWidth="1px"/>
        <DynamicHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
      </asp:Menu>
      </td>       
      </tr>
    </table>
    <h3>OCS VIEW</h3>            
      <asp:ContentPlaceHolder id="ContentPlaceHolderOCS" runat="server">
        <!-- ! OCS CHILD PAGES CODE GOES HERE ! -->
      </asp:ContentPlaceHolder>
    </asp:View>   

    <asp:View ID="vwSC" runat="server" EnableViewState="true" EnableTheming="False">
    <table class="ICMMainMenuTable" width="100%">
      <tr>
      <td align="left">
      <asp:Menu
        id="mnuSafeConnect"
            runat="server"
            BackColor="#e5e5e5"
            DynamicHorizontalOffset="2"
            Font-Names="Verdana"
            Font-Size="Small"
            ForeColor="#000000"
            Orientation="Horizontal"               
            StaticSubMenuIndent="10px" AccessKey="M">

        <StaticSelectedStyle BackColor="White" ForeColor="black" Font-Bold="True" BorderStyle="Inset" BorderWidth="1px" BorderColor="Red" />              
        <StaticHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
        <StaticMenuItemStyle HorizontalPadding="10px" VerticalPadding="2px"/>       
   
        <DynamicMenuStyle BackColor="White" BorderStyle="Solid" BorderWidth="1px"/>
        <DynamicHoverStyle BackColor="#e5e5e5" ForeColor="Black" Font-Underline="True" />
        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
      </asp:Menu>
     </td>       
     </tr>
    </table>
    <h3>Safe Connect VIEW</h3>
      <asp:ContentPlaceHolder id="ContentPlaceHolderSC" runat="server">
        <!-- ! SafeCon CHILD PAGES CODE GOES HERE ! -->
      </asp:ContentPlaceHolder>        
    </asp:View>  
  </asp:MultiView>
<!-- END MultiView -->

>>>Code Behind:<<<
protected void MenuMain_MenuItemClick(object sender, MenuEventArgs e)
  {
  menuView = Int32.Parse(e.Item.Value);

  switch (menuView)
  {
  case (int)SystemType.DIW:
    MultiView1.ActiveViewIndex = menuView;
    break;
  case (int)SystemType.OCS:
    MultiView1.ActiveViewIndex = menuView;
    break;
  case (int)SystemType.SafeConnect:
    MultiView1.ActiveViewIndex = menuView;
    break;
  default:
    MultiView1.ActiveViewIndex = (int)SystemType.NotSet;
    break;
  }
  }
  protected void Page_Load(object sender, EventArgs e)
  {
  role = Convert.ToInt32(Session["Role"]);
  try
  {
    if (IsPostBack == false)
    {
    LoadMenusSafeConnect(role);
    LoadMenusDIW(3);
    LoadMenusOCS(3);

    MultiView1.ActiveViewIndex = Convert.ToInt32(SystemType.DIW); //default on load
    MenuMain.Items[MultiView1.ActiveViewIndex].Selected = true;
    }
   
    MultiView1.ActiveViewIndex = menuView;
    MenuMain.Items[menuView].Selected = true;
   }
  catch (Exception ex)
  {
    LogFile errWriter = (LogFile)Application["LoggerMgr"];
    errWriter.WriteErrorLog(ex);
    Server.Transfer("ErrorsDisplay.aspx?ErrMsg=" + ex.Message);
  }
  }

v


Answers (2)