有几个页面,都有相同的页脚,我怎么把页脚像ASP中的 include file 一样整合到网页中呢?说明:该页脚的显示是动态的,就是如果把页脚存成一个文件的话它的里边需要写程序!

解决方案 »

  1.   

    用户控件
    把你的页脚里的<html><body> 都去掉
    保存为foot.ascx
    1.在使用到它的页面
    <%@ Register TagPrefix="A" TagName="B" Src="路径/foot.ascx" %>
    A B 为任意
    2。在使用它的地方
    <a:b id="kdfjkd" runat="server" />
      

  2.   

    把页脚写成一个用户控件,在vs.net中添加新项,选择web用户控件。然后在其他页面用你做好的用户控件就行<%@ Register TagPrefix="uc1" TagName="buttom" Src="buttom.ascx" %><uc1:buttom id="buttom1" runat="server"></uc1:buttom>自己找找用户控件了
      

  3.   

    用户控件里的<form>也要去掉
    一个页面里只能有一个<form>
      

  4.   

    <% Server.Execute("WebForm2.aspx");%>这样写就可以不过最好是写成控件
      

  5.   

    控件最好
    写一个foot.html 加入html     
    jf
      

  6.   

    定义用户控件
    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="Footer.ascx.cs" Inherits="trainingsample.Footer" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %><table width="745" border="0" align="center" cellpadding="0" cellspacing="0">
    </table>
    使用用户控件
    <%@ Register TagPrefix="trainingsample" TagName="Footer" Src="Footer.ascx" %><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>站点地图</title>
    <link href="imags/main.css" rel="stylesheet" type="text/css">
    </head><body background="imags/index_bgpic.jpg" leftmargin="0" topmargin="0" MS_POSITIONING="GridLayout">
    <!-- 导航栏开始 -->
    <form id="Form1" method="post" runat="server"><table width="745" border="0" align="center" cellpadding="0" cellspacing="0" class="tab">
    <table width="745" border="0" align="center" cellpadding="0" cellspacing="0" class="tab">
      <tr>
        <td><trainingsample:footer id="Footer1" runat="server"></trainingsample:footer>
            </td> </tr>
             
    </table></form>
    <!-- copyright结束 -->
    </body>
    </html>
      

  7.   

    用继承,继承的类重新输出HTML
    protected override void Render(HtmlTextWriter writer)
    {
         base.Render (writer);
         这里写页脚就可以了
    }
      

  8.   

    <%@ Register TagPrefix="uc1" TagName="buttom" Src="buttom.ascx" %><uc1:buttom id="buttom1" runat="server"></uc1:buttom>