Archive for May, 2008

Get the .NET framework version

Friday, May 30th, 2008

Microsoft has released two versions of the .NET framework so far, and sometimes might be useful to know which version of the framework is your web host running. You can obtain this information easily with ASP.NET and here is how.

Create a new ASP.NET file and call it framework_version.aspx or any other name you want. Copy and paste the following code there:

<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="False"%>

<script language="VB" runat=server>

Sub Page_Load(Sender as Object, E as EventArgs)

Response.Write(".NET framework version: " & System.Environment.Version)

End Sub

</script>

Upload this to your web hosting account and then load the page in your browser and you will see something like:

.NET framework version: 1.1.4322.573

or

.NET framework version: 1.0.3705

Eval() and Execute() ASP/VBScript functions

Thursday, May 29th, 2008

Microsoft has released 2 very useful functions with Microsoft Visual Basic Scripting Edition 5.0, namely Eval() and Execute() functions. We will compare those 2 functions and give examples of their use in this article.

The Eval() VBScript function evaluates an expression and returns the result. Consider the following line of VBScript code:

Var1 = Var2

You can interpret this statement in 2 completely different ways. The first one is "the value of Var2 is assigned to Var1” and the second one is "Var1 is compared to Var2”. The Eval() VBScript function always uses the second interpretation and returns Boolean value - True or False. For example consider the following ASP code:

<%

Var1 = 1
Var2 = 2
Response.Write(Eval("Var1 = Var2 &#43 1")) ‘ Prints False
Response.Write(Var1) ‘ Prints 1, even after the Eval() function execution on the previous line
Response.Write(Eval("Var1 = Var2 - 1")) ‘ Prints True

%>

The Execute() VBScript function uses the first interpretation we talked about earlier, which actually evaluates the expression parameter. For example the following ASP/VBScript code will print 5 in the browser:

<%

Var1 = 1
Var2 = 2
Execute("Var1 = Var2 &#43 3")
Response.Write (Var1) ‘ Prints 5
%>

Niche Marketing