0

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"%> 

and

<!--#include file="alg/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

Thanks for any help!

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

4 Comments

One of the errors I got is 'square is not defined' in the main file, as it doesn't seem to be including the class properly or something. I'm unsure what a code behind sheet is, but can I use multiple of these?
"en.wikipedia.org/wiki/ASP.NET" Theres also something about Code-Behind. Normally, every simple page got an extra Code-Behind-Sheet. With which IDE do you write?
I'm using Visual Studio but I'm very new to developing ASP.net, I've done a ton of classic ASP though and I just used to have a whole load of include statements.
I guess you should try the Code-Behind, so you have the Design in the aspx-pages and the coding and dynamic behaviour in the Code-Behind-pages. So, I would advice you to read a Code-Behind-Tutorial, because this is on of the most important and best changes of .NET, so it should not only solve your problem but improve your skills.
1

You should not need to use include or register to access a class. You just need to save your class to a class file (.vb) and put the class in your app_code directory (if you are using a website project) or put it anywhere in a web application project (preferrably a folder for classes) but include it in your project namespace. This should make your class visible anywhere in the website or web application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.