The way to code, develop and build a website, intranet or application between asp classic and asp .net are different. In my opinion, those differences is a lot.
Even though, they are possess similar programming language like visual basic but the mind set to develop, in common ways, both are not same. Developer who used to use asp classic learn asp .net will find a new things.
However, in this post, I give example on how to convert asp classic to asp .net so that it can be run on web hosting which supports .net. Convertion will use ‘asp classic’ like code. It does not use any software tools.
Asp classic developers can use their experties to build .aspx website. Again they also need to learn asp .net controls and recommended methods from Microsoft to build an application because it increases productivity.
Let’s assume we have database table ‘tb_customers’ with just two columns which are customer and city. The .aspx files that has asp classic code like will operate with that table using ADODB objects
Summary of the things to note are as below:
- Add page directive on top of script.
- Every variables must be declared with ‘dim’.
- ‘Let’ and ‘Set’ assignment statements are no longer supported. Do not use ‘Set’ assignment in your script anymore.
- Every functions and procedures must have open/close parantheses on its arguments / parameters i.e response.write(“hello”) instead of response.write “hello”
- When getting recordset field value, it must use complete syntax (with ‘.value’) i.e rs(“fieldname”).value
Only few things we need to consider and here is the example of .aspx file:
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
conn = Server.CreateObject("ADODB.Connection")
conn.open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.mappath(".") & "\dbtest.mdb")
rs = Server.CreateObject("ADODB.Recordset")
rs.PageSize = 10
rs.CursorLocation = adUseClient
rs.open ("Select * from tb_customer", conn, adOpenForwardOnly, adLockReadOnly)
If Len(Request.QueryString("page")) = 0 Then
rs.AbsolutePage = 1
If CInt(Request.QueryString("page")) <= rs.PageCount Then
rs.AbsolutePage = Request.QueryString("page")
rs.AbsolutePage = 1
Dim abspage, pagecnt
abspage = rs.AbsolutePage
pagecnt = rs.PageCount
response.write ("<table id='thetable' border=1 width='50%'>")
dim i, j, f
for each f in rs.Fields
response.write ("<th>" & f.Name & "</th>")
if not rs.EOF then
for i = 1 to rs.PageSize
if rs.EOf then exit for
response.write ("<tr><td>" & rs(0).value & "</td>")
for j = 1 to rs.Fields.Count -1
if not isdbnull(rs(j).value) then
response.write ("<tr><td colspan=" & (rs.fields.count) & ">")
if pagecnt > 1 then
for i = 1 to pagecnt
response.write ("<a href='default.aspx?page=" & i & "'>" & i & "</a> ")
Save as default.aspx then run it