Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
in master page i want to load other page in a main div. so that other page can take the rest width of its parent div in master page. but its not loading in that div whose id="maindiv".


What I have tried:

enter code here
  <html>
  <head>
  <script>
  //here we make a function to visible one menubar at a time.
  var count = 0;
  function Nav() {

  if (count % 2 == 1) {

  document.getElementById("menu").style.width = "200px";
  document.getElementById('largediv').style.display = "block";
  document.getElementById('smalldiv').style.display = "none";
  count++;
  }
  else {

  document.getElementById("menu").style.width = "70px";
  document.getElementById('largediv').style.display = "none";
  document.getElementById('smalldiv').style.display = "block";
  count++;
  }
  }
  </script>
  </head>
  <body>
  <div  id="header" onclick="Nav();" style="position: fixed; display: block;
  z-index: 1;">
  Header </div>
  <div style="display:table; width:100%;">
  <div id="menu" style="display:table-cell; width: 200px;"> Side Menu Bar
  </div>
  <div id="maindiv" style="display:table-cell;"> Main Div </div>
  </div>

  <div id="largediv" style=" width:200px; position:fixed;"> </div>
  <div id="smalldiv" style="display:none; width:70px;
  position:fixed;">
  </body>
  </html>
Posted
Updated 15-Jun-17 18:21pm
Comments
F-ES Sitecore 15-Jun-17 4:20am    
I don't see how the code relates to the question....I don't see anywhere where anything is loaded into anything
Richard Deeming 15-Jun-17 13:40pm    
I suspect you need to get together with Member 13196273 and learn how ASP.NET master pages work:
How we take defaut page in master page div[^]

I guess no one take an effort to resolve this issue but let me give it a try and lets see if you like this explanation. Okay?

First you have to create a masterpage and your master page must look like this.

<%@ Master Language="C#" CodeBehind="MASTER_PAGE_NAME.Master.cs" Inherits="PROJECT_NAME_Page1" %> // the top should look like this right? if you are using asp

//below you will see this

<asp:ContentPlaceHolder ID="head" runat="server">
// this is where i put my css stylesheet links so that all content pages of your master page can use it.
</asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="main" runat="server">
//this is where you want to put your main div
<div id="maindiv">
//this is where you want to show your outputs right?
</div>
</asp:ContentPlaceHolder>



Last you need to create a content page for your masterpage by rightclicking your masterpage on solution explorer and click "Add Content Page"


<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="MASTER_PAGE_NAME.Master"
CodeBehind="Admin.aspx.cs" Inherits="PROJECT_NAME.CONTENT_PAGE_NAME" %> // the top of your content page will look like this.

// you will have this too on your content page
<asp:ContentPlaceHolder ID="head" runat="server">
//put 1 or more links from your masterpage that you think this page will use.
</asp:ContentPlaceHolder>

// and this one too
<asp:ContentPlaceHolder ID="main" runat="server">
//create a function here that this page will run.
</asp:ContentPlaceHolder>
 
Share this answer
 
Using jQurey you can add any external page to a DIV element. See the example.
<div id="nav"></div>

<script>
   $(function () {
      $("#nav").load("http://localhost:12345/YourPage.htm");
   });
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900