Migrating Include files From ASP to ASP.net

Discussion in 'ASP.NET / ASP.NET Core' started by planetscott, May 1, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello,

    In programming ASP, I often used "includes" files to
    store subroutines and functions used in many pages. I cannot seem to get this model to work in ASP.net. What am I missing?

    Example - Does Not Work
    File index.aspx
    <script runat="server">

    DoThis()

    </script>
    <!--#include file=code.ascx-->

    File code.ascx
    <script runat="server">

    Sub DoThis()
    Do some things here
    End Sub

    </script>

    But this works just fine
    File index.aspx
    <script runat="server">

    DoThis()

    Sub DoThis()
    Do some things here
    End Sub

    </script>
     
  2. I am not yet an expert in ASP.NET so my response may be wrong, but since the file you are trying to include is an ascx file, it will work as a custom control. Include it in the page that way.

    Put this at the top of the aspx page in which you want to include the ascx file (modify to fit your needs)

    <%@ Register TagPrefix="jdp" TagName="PageHeader" Src="header.ascx" %>

    Then in the body of the page, put something like this:

    <jdp:pageHeader runat="server" />

    See how that works for you.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page