I first followed the procedure to register a .Net assembly using regasm on the web server as below (http://weblogs.asp.net/dneimke/archive/2004/01/31/65330.aspx)
- Make sure your assembly has a strong name to install it in the GAC
- Run regasm /tlb “<path of your assembly>”
- Add the assembly to the GAC
This allows your assembly to be accessible in your ASP code to create server side objects
In my example I have a .Net assembly which has a class as below
using System; using System.Collections; namespace API { /// <summary> /// Summary description for Versions. /// </summary> public class Versions { ArrayList versions = new ArrayList(); public Versions() { versions.Add(“1”); versions.Add(“2”); versions.Add(“3”); } public ArrayList List { get { return versions; } } } }
I initially tried to have a method in my .Net class return an ArrayList, Then I tried to create an object of type “System.Collections.ArrayList” in ASP and iterate the object in ASP, as the array list type definition was not supported when the asp code executed. So I created the class above which had a public property having a type of System.Collections.ArrayList
So now in ASP I did the following and it printed out the arrray list on my asp page
<%@ codePage="65001" %> <html> <head> <title>Test Page</title> <%1:
2: set versions = Server.CreateObject("Versions")3: For Each v in versions.List4: Response.Write(v & "</br>")5: Next
6:
%> </head> <body></body> </html>
That can be further enhanced in your ASP code to achieve the functionality you need to
No comments:
Post a Comment