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