如何包括其他页面,aspx文件 [英] How to include other page to aspx file

查看:222
本文介绍了如何包括其他页面,aspx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net其他aspx文件主aspx文件我能做到这一点在JSP中JSP中code包括像

 < JSP:包括页=footer.jsp中/>


解决方案

您不能在另一个页面添加到asp.net现有的页面。

因为 asp.net 不允许两个 form标签在同一页面。

有喜欢的用户控制功能,你可以使用

更多详细信息

HTTP://www.$c$cproject.com /文章/ 1739 /用户控制功能于ASP-NET

编辑1

更进一步

主网页的概念内容页

这里是一个很好的链接,母版页

http://www.$c$cproject.com/Articles/325865/Creating-Master-Page-In-ASP-NET-2010

编辑2

法师页面有类似下面的结构

 <%@主语言=C#AutoEventWireup =真
codeFILE =MasterPage.master.cs继承=母版%GT;!< D​​OCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
<头=服务器>
   <标题>< /标题>
   < ASP:的ContentPlaceHolder ID =头=服务器>
   < / ASP:&的ContentPlaceHolder GT;
< /头>
<身体GT;
   <表ID =form1的=服务器>
      < D​​IV>
          < ASP:的ContentPlaceHolder ID =ContentPlaceHolder1=服务器>          < / ASP:&的ContentPlaceHolder GT;
      < / DIV>
   < /表及GT;
 < /身体GT;
< / HTML>

要注意的

很少点


当你箱页面,你只能在 ContentPlaceHolder1 添加内容,可以有很多的这些。


你可以把你的用户控件母版页也使得它都会对你的网页中反映出来。

编辑3

母版页

实际上是用户控件;你可以到你的母版页类的code-背后验证这一点,在类名称上点击右键并选择转到定义。你会看到这样的事情:

 公共类母版:用户控件
{
    ...
}

用户控件

是便于被反复withing单个项目显示元件,例如菜单和面板。的问题是,它们不会产生.DLL文件并且必须手工复制到其它的项目,如果需要的话。



一些好的链接


相当于ASP.NET服务器端包含

<一href=\"http://stackoverflow.com/questions/6938046/how-to-include-an-external-html-file-in-asp-net-page\">How包括在asp.net页面外部HTML文件

i want to include other aspx file to main aspx file in asp.net i could do it in jsp the code in jsp include like that

<jsp:include page="footer.jsp" />

解决方案

You can not add another page to the existing page in asp.net.
Because asp.net does not allow two form tag in the same page.
There are feature like user control which you can use
More detail
http://www.codeproject.com/Articles/1739/User-controls-in-ASP-NET

Edit 1

Further more
There is a concept of Master page and content page
Here is a good link for master page
http://www.codeproject.com/Articles/325865/Creating-Master-Page-In-ASP-NET-2010

Edit 2

Master page has a structure like below

<%@ 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:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

          </asp:ContentPlaceHolder>
      </div>
   </form>
 </body>
</html>

Few point to be noted
When you crate a Page you can add content only in ContentPlaceHolder1, there can be many of these.
You can put your user-control inside master-page also so that it will be reflected all over you pages.

Edit 3

Master pages

are actually user controls; you can verify this by going to the code-behind of your master page class, right-click on the class name and select "Go To Definition". You will see something like this:

public class MasterPage : UserControl
{
    ...
}

User controls

are convenient for display components that are repeated withing a single project, such as menus and panels. The problem is that they do not generate .DLLs and have to be hand-copied to other projects, if needed.

Some good links
ASP.NET equivalent of server side includes
How to include an external html file in asp.net page

这篇关于如何包括其他页面,aspx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆