SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help me with Includes in Aspx.net when using

    Hello Everyone,

    How can I call or use includes in aspx.net. I am developing web application and I want header and footer of the application to be independent or on different page then just called or included in the main page. The header and footer are as folows
    Header.aspx and Footer.aspx respectively. How do I include or call them in index.aspx page????

    Your help will be highly appreciated.
    Zamzam

  2. #2
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,880
    Mentioned
    48 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Well, your best option would be to use a Master Page. If thats not possible coz ur using asp.net 1.1 or something.

    Then next best thing would be WebUserControls. eg:
    Header.ascx, Footer.ascx then use them as follows:

    At the top of the aspx page:
    <&#37;@ Register src="/Header.ascx" tagname="Header" tagprefix="ic" %>
    <%@ Register src="/Footer.ascx" tagname="Footer" tagprefix="ic" %>

    Where you want them to appear in aspx page:
    <ic:Header ID="Header" runat="server" />
    <ic:Footer ID="Footer" runat="server" />

    Or if none of the above is an option coz you already have the header and footer pages as aspx pages and its not viable to change them you can use a simple include statement as follows:

    <!--#INCLUDE file="/Header.aspx" -->
    <!--#INCLUDE file="/Footer.aspx" -->

    I hope this helps

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    Sep 2002
    Location
    Cleveland, Ohio, USA
    Posts
    1,494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't use includes. It's no the ASP.NET way.

    I suggest looking into the control tree structure of a page and use that as a jumping off point. Furthermore, if you want to use the same template for every page, use master pages and not included UserControls.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •