How to include another page in aspx file

I want to include another aspx file in the main aspx file in asp.net. I could do it in jsp, the code in jsp includes such

<jsp:include page="footer.jsp" />
+5
source share
4 answers

You cannot add another page to an existing page in asp.net.
Because it asp.netdoes not allow two form tagon one page.
There is a function, such as user control, which you can use
Read more
http://www.codeproject.com/Articles/1739/User-controls-in-ASP-NET

Change 1


Master page content page

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

2

,

<%@ 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>

,
, ContentPlaceHolder1, .
user-control master-page , .

3

-

- ; , , " ". - :

public class MasterPage : UserControl
{
    ...
}

, , . , .DLL .


ASP.NET
html asp.net

+3

. , :

<div ID="menuContent" runat="server">
    <!-- #Include virtual="/menu.aspx" -->
</div>   

menu.aspx raw html #, ASP . ?

+8

ASP.Net - - .

If you are using ASP.Net MVC, we have the concept of Partial View.

+1
source

Using #include will not work because it will present two page directives if the included file is an ASP.NET page. The OP will have to use Ajax to download the file, and then put it on the page.

0
source

All Articles