我们如何在母版div中加载其他页面。 [英] How can we load other pages in a div of master page.
本文介绍了我们如何在母版div中加载其他页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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>
推荐答案
我想没有人会努力解决这个问题,但让我试一试,看看是否你喜欢这个解释。好的?
首先,你必须创建一个母版页,你的母版页必须如下所示。
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>
使用jQurey,您可以将任何外部页面添加到DIV元素。请参阅示例。
Using jQurey you can add any external page to a DIV element. See the example.
<div id="nav"></div>
<script>
(function(){
(function () {
这篇关于我们如何在母版div中加载其他页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文