ASP.NET Includes Text or HTML Files into ASPX pages

  • Thread starter Thread starter Bari
  • Start date Start date
B

Bari

I'm trying to find out how to INCLUDE a file (text or html
etc) into my ASPX page.
I don't want to know how to create a user control etc just
a quick simple example.

Looking for something similar to the old fashioned ASP
include <!--#include file="time.inc"--> but a .NET version.
 
Bari said:
I'm trying to find out how to INCLUDE a file (text or html
etc) into my ASPX page.
I don't want to know how to create a user control etc just
a quick simple example.

Looking for something similar to the old fashioned ASP
include <!--#include file="time.inc"--> but a .NET version.


Hmmm, UserControls ARE the .NET version of how this is done, yet you DON'T
want that?!

Could you tell me how to put 10 gallons of water into a 5 gallon bucket all
at once please?
 
Traditional #include is nit really a good option for the OO nature of
asp.net. The correct approach is to use user controls, but they can be very
simple to implement.

Add this line to the top of your aspx page
includeme.ascx is the equivalent of the old include file with your HTML
etc, in my case it is a navigation menu

<%@ Register TagPrefix="myProject" TagName="includedthing"
Src="includeme.ascx" %>

To position the include file in the page add the line below to you ASPX
page

<myProject:menu:includedthing ID="myfirstinclude" runat="server" />

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
Or better yet, in VS.NET, just drag the UserControl (.ascx file) on to the
host page at the desired location and you are done!
 
that would indeed do it in vs.net..........(old hardcore developers like me
like to do it the old fashioned way - notepad and the SDK )

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------
 
I am also an "old hardcore", "Visual" Notepad using developer, but if I can
find a way for VS to generate the exact same (emphasis on "exact same") code
that I would have had to have written, I'll take it!
 
Back
Top