在ASP.net中包含代码

问题描述:

我有一个ASP.net文件,我试图包括动态代码,这在经典ASP中很容易.

I've got an ASP.net file, and I'm trying to include dynamic code which was easy in classic ASP.

这是我到目前为止尝试过的:

Here is what I have tried so far:

<%@ Register TagPrefix="TagPre" TagName="header" Src="alg/classes.aspx"%> 

<!--#include file="alg/classes.aspx"-->

但是这些似乎都不起作用.classes.aspx的内容是:

But neither of these seem to work. The content of classes.aspx is:

<script runat="server">   
' Square class
Public Class square

    Public sqRows As Integer        'Numbers of rows this square has
    Public sqCols As Integer        'Number of columns this square has
    Public sqArray(,) As Integer    'The square array

    ' Initialise square array to match size of canvas
    Public Sub initSqArray(ByVal canvCols, ByVal canvRows)
        ReDim sqArray(canvCols, canvRows)
        sqRows = canvRows
        sqCols = canvCols
    End Sub

End Class

感谢您的帮助!

您遇到的具体问题或错误是什么?当您使用.aspx时,您是否已经尝试过将VB代码放在代码隐藏表"中并从那里拉出来?

What is the concrete problem or error you got? When you are using .aspx, did you already try to put the VB-Code in the Code-Behind-Sheet and pull it from there?