Asp.net 动态加载页面中的多个页面
我有一个用c#,ASP.NET编写的网站。我想根据左侧菜单中的链接动态加载右侧div中的页面。但我不知道从哪里开始,哪个控件等等。。 请帮帮我Asp.net 动态加载页面中的多个页面,asp.net,c#-4.0,Asp.net,C# 4.0,我有一个用c#,ASP.NET编写的网站。我想根据左侧菜单中的链接动态加载右侧div中的页面。但我不知道从哪里开始,哪个控件等等。。 请帮帮我 使用右侧的iframe标记来包含动态加载的页面,然后在右侧链接的目标属性中指定iframe的name属性 <table> <tr> <td> <a href='www.reddit.com/r/jquery' target='contentFrame'>first Link</a&g
使用右侧的iframe标记来包含动态加载的页面,然后在右侧链接的目标属性中指定iframe的name属性
<table>
<tr>
<td>
<a href='www.reddit.com/r/jquery' target='contentFrame'>first Link</a> <br/>
<a href='www.reddit.com/r/javascript' target='contentFrame'>Second Link</a>
</td>
<td>
<iframe name='contentFrame' />
</td>
</tr>
</table>
有多种方法可以做到这一点。一种简单的方法是使用CSS
创建布局(即左侧的菜单,右侧的内容)和母版页
。母版页是一个模板,当其他页面有共同的方面时,可以使用该模板。在这里,左侧的菜单对于所有页面都是通用的,因此您可以在母版页中创建该布局。每个页面(例如,firstpage.aspx
)都继承该母版页,您只需填写右侧的内容即可
有很多CSS资源,但可能会帮助您开始使用布局方面。有关母版页的更多信息可以找到
其他方法包括使用AJAX动态加载页面。根据您的设计,这可能有点棘手。使用母版页和内容页 例如: 母板页 当您定义这样的页面时,它们被称为内容页面 页面的内容在
内容控件中定义:
<asp:Content ID="Content1" ContentPlaceHolderID="mainPlaceHolder" runat="server">
还要注意母版页
的内容占位符
ID和内容
的内容占位符ID
属性之间的名称必须如何匹配
<%@ Page Title="" Language="C#" MasterPageFile="~/path to your masterfile.Master" AutoEventWireup="true" CodeBehind="page code behind" Inherits="page class" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainPlaceHolder" runat="server">
<h3>
Your cool content here
</h3>
</asp:Content>
<%@ Page MasterPageFile="~/path to your masterfile.Master"
<asp:Content ID="Content1" ContentPlaceHolderID="mainPlaceHolder" runat="server">