Tutorial-Web Home > An Overview in the Differences Between ASP and ASP.net > Section 2: ASP.net Differences 1










Site Menu

An Overview in Creating an ActiveX DLL for Use with ASP Scripts

Available ActiveX Components for Download

Search the Web for other ASP Tutorials

Subscribe to Tutorial-web's mailing list.

A Note From the Author

A Good ASP.net Resource
cover
More Resources











Rendered Ineffective

The largest basic programming difference between ASP and ASP.net is the lost ability to program page-render functions. This means there will no longer be ASP functions with HTML intertwined throughout. I perceive this as the most radical change for current ASP programmers. One of the strengths of ASP was to easily drop functions into existing HTML web pages without much re-coding. ASP.net requires any HTML that appears within functions to be written to the screen using the response.write function.

ASP:

<%
Option Explicit
Function PrintHello
Dim i
For i= 1 to 5

%> <font size=<%=i%>>Hello</font>> <%
Next
End Function
%>

Asp.net:

<%
Option Explicit
Function PrintHello()
Dim i
For i= 1 to 5

response.write("<font size=" & i & "> Hello")

<%
Next
End Function
%>

Declaration of Independence from <%

When a function is declared in ASP.net it must appear in a <script runat=server> block with the language declared. The days of <% %> whenever ASP was needed are gone. We must be careful to make sure our functions exist in these blocks or else they will generate an error.

ASP:

<%
Sub HelloWrite()
Response.Write "Hello World"
End Sub

HelloWrite
%>

Asp.net:

<script language="VB" runat=server>

Sub HelloWrite()
Response.Write "Hello World"
End Sub

</script>

<%
HelloWrite()
%>

An added change that you may notice as well is that function calls require that the parentheses () appear after the function name. I have gotten it to work without the parentheses but I think officially it is required.

Previous    Next


Sections

Section 1: Introduction
Section 2: ASP.net Differences 1
Section 3: ASP.net Differences 2
Section 4: Final Differences and Conclusion

Sponsors

Search Now:
In Association with Amazon.com
www.goto.com Search the Web.
Type it and go!
  

Counter