|
Using out-process components under IIS4
|
Total Hit (2834) |
By default IIS 4 doesn't permit to use the Server.CreateObject command with an out-process ActiveX EXE component. To do so, you must manually create the AllowOutOfProcCmpts registry value under the path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\ASP\Parameters, and set its value to 1
....Read More |
Rating
|
|
|
A better way to query for a single node
|
Total Hit (2582) |
In the XmlNode class, that is the class that provides node functionality in an XMLDOM representation of an XML document, the SelectNodes (and the ancillary SelectSingleNode) method exploits the XPath query language to let you extract nodes based on logical conditions. The SelectNodes methods return
....Read More |
Rating
|
|
|
Handle child XML nodes with care
|
Total Hit (2708) |
When you work with XML documents loaded into an XmlDocument class, you often need to examine the contents of child nodes. The XMLDOM programming interface purposedly provides the ChildNodes property. In the .NET XmlDocument class, ChildNodes returns an internal object of type XmlChildNodes. (The obj
....Read More |
Rating
|
|
|
Formatting dates with VB.NET and ASP.NET
|
Total Hit (3258) |
«B»This tutorial covers formatting dates. To follow this tutorial, there are some basic requirements:«/B»
A text editor or a visual web design program with HTML editing capabilities installed on your computer since this exercise will require hand coding. Examples include Notepad, Homesite, or
....Read More |
Rating
|
|
|
Windows Installer Appears Every Time I Start an Application
|
Total Hit (4685) |
Intended For
Windows XP
Windows 2000
The Windows Installer is a global application used to install many Microsoft products, including Office 2000 and Office XP, and is even available to third-party developers to include with their programs.
Unfortunately, it's fraught with bugs, one of
....Read More |
Rating
|
|
|
|
CompareList - Compare an argument with a list of values
|
Total Hit (2440) |
«Code LangId=1»
' Return the position of the argument in a list of values
' or zero if the argument isn't included in the list
' It works for both regular values and for objects
'
' This handy function can often save you a lengthy Select Case
' statement or a complex series of If...ElseIf blo
....Read More |
Rating
|
|
|
CompareValue - Check whether a value is in a list of values
|
Total Hit (1890) |
«Code LangId=1»' Compares a numeric or string value with a list of other values.
' Returns the 1-based index of the matching value, or zero if the
' value doesn't appear in the list.
' String comparisons are case-sensitive.
'
' This function can conveniently replace a Select Case or a list
'
....Read More |
Rating
|
|
|
IsValidEmail - Validate an email address
|
Total Hit (2910) |
«Code LangId=1»' Validates an email address
' Returns True if valid, False if invalid
'
' Example:
' If IsValidEmail(Value:="x@y.com", MaxLength:=255, IsRequired:=True) then ...
Function IsValidEmail(ByRef Value As String, Optional ByVal MaxLength As Long = _
255, Optional ByVal IsRequi
....Read More |
Rating
|
|
|
IsValidSSN - Check a Social Security Number value
|
Total Hit (3174) |
«Code LangId=1»' Validates attributes of the SSN
' Returns True if valid, False if invalid
'
'Example:
' If IsValidSSN(Value:="333-44-3333", IsRequired:=True) then ...
Function IsValidSSN(ByRef Value As String, Optional ByVal IsRequired As Boolean _
= True) As Boolean
On Error
....Read More |
Rating
|
|
|
KeepInRange - Ensure that a value is in a given range
|
Total Hit (1601) |
«Code LangId=1»' Keep the first argument in the range [lowLimit, highLimit]
' If the value is adjusted, the fourth (optional) argument is set to True
'
' Note that value and limit arguments are variant, so you can use
' this routine with any type of data.
Function KeepInRange(value As Varian
....Read More |
Rating
|
|
|
NZ - Check whether a value is Null
|
Total Hit (1736) |
«Code LangId=1»' Check if a value is Null. If not it returns the value,
' otherwise it returns the ValIfNull argument, or zero/null string
' if the second argument is omitted
'
' This function is patterned after the Access function with the same name.
Public Function NZ(CheckVar As Varian
....Read More |
Rating
|
|
|
ProjectName - The name of the current project
|
Total Hit (1890) |
«Code LangId=1»' Returns the name of the current project
' The first time it's called it clears the error code
'
Function ProjectName() As String
Static result As String
If Len(result) = 0 Then
On Error Resume Next
' cause a dummy, harmless error
Err.Raise 9
....Read More |
Rating
|
|
|
|
Ask a Yes/no question and return a Boolean
|
Total Hit (2912) |
«Code LangId=2»
' Ask a Yes/no question
' returns True if the user replies "Yes"
' Example: MessageBox.Show(AskYesOrNo("Do you like me?", "ME", True))
Function AskYesOrNo(ByVal text As String, ByVal title As String, _
ByVal defaultAnswer As Boolean) As Boolean
Dim defButton As Messa
....Read More |
Rating
|
|
|
CompareList - Compare an argument with a list of values
|
Total Hit (2640) |
«Code LangId=2»' Return the position of the argument in a list of values
' or zero if the argument isn't included in the list
' It works for both regular values and for objects
'
' This handy function can often save you a lengthy Select Case
' statement or a complex series of If...ElseIf block
....Read More |
Rating
|
|
|
Large or nested include files can affect ASP performance
|
Total Hit (5540) |
All include files appear to the ASP processor as belonging to the main ASP file, therefore they are read in memory and parsed as if they were physically pasted into the main ASP file. Therefore, while you should use include files for holding commonly used routines, you should be aware that the longe
....Read More |
Rating
|
|
|
Let ASP determine whether cookies are enabled
|
Total Hit (3117) |
Most web sites heavily rely on client-side cookies. For example, ASP Sessions can work correctly only if the browser allows temporary cookies (that are not stored on disk). ASP doesn't provide any native method to understand whether cookies are enabled or not, but you can use the following code:
....Read More |
Rating
|
|
|
Miscellaneous tips for improving ASP performance and robustness
|
Total Hit (6116) |
Here's a collection of quick-and-dirty tips for improve the performance and the robustness of your ASP applications:
Use the Option Explicit directive to ensure that all variables are correctly declared and scoped. Mistyping a variable name is one of the most frequent causes of bugs inside ASP
....Read More |
Rating
|
|
|
Ensure that server-side debugging is disabled in production sites
|
Total Hit (5293) |
Before going to production, you should ensure that the server-side script debugging is off for your ASP application. In fact, not only does server-side debugging slow down your application, it also forces all ASP request to be served by the same thread. In other words, you don't take advantage of II
....Read More |
Rating
|
|
|
Quickly create HTML tables from an ADO Recordset
|
Total Hit (5915) |
The ADO Recordset object exposes the GetString method, which returns the values in the Recordset into a formatted string. Here's its syntax:
res = GetString([StringFormat As StringFormatEnum = adClipString], _
[NumRows As Long = -1], [ColumnDelimeter As String], _
[RowDelimeter As Str
....Read More |
Rating
|
|
|
Redirect the browser when the output has already been sent
|
Total Hit (3711) |
If from an ASP page you try to use Response.Redirect after having written anything to the browser, you'll get an error saying that the page's headers have already been written. To avoid this you should put the code that checks if the browser needs to be redirected to another page at the very beginni
....Read More |
Rating
|
|
|
Split large HTML tables in smaller ones
|
Total Hit (2924) |
In general, a browser can't render an HTML table before the closing &/TABLE> tag is received. This means that the end user might wait for several seconds before a table result is displayed. The easiest way to have results appear as soon as they are available is subdivide a large HTML table into many
....Read More |
Rating
|
|
|
The MapPath method slows down execution
|
Total Hit (5214) |
The Server.MapPath method slightly shows down the execution of your ASP scripts, because IIS has to access some internal variables. For this reason you should try to avoid it if possible. In other words, you should code absolute physical paths in your ASP code, instead of using virtual paths that yo
....Read More |
Rating
|
|
|
Tricks with Server.MapPath
|
Total Hit (3008) |
The Server.MapPath method can be used to retrieve several interesting properties about the running ASP application, for example:
«Code LangId=5»
' the current directory
currDir = Server.MapPath(".")
' the parent directory
parentDir = Server.MapPath("..")
' the application's root director
....Read More |
Rating
|
|
|
Two ways to access ASP objects from within a component
|
Total Hit (8870) |
You can write ASP components that work under any version of IIS by adding a special public method, named OnStartPage, to the public class module of the ActiveX DLL project. This method is then called by IIS whenever a script instantiates an object through the Server.CreateObject command. This is the
....Read More |
Rating
|
|
|
Understanding IIS Isolation Levels
|
Total Hit (3210) |
Internet Information Server introduced the notion "Isolation Level", which is also present in IIS4 under a different name. IIS5 supports three isolation levels, that you can set from the Home Directory tab of the site's Properties dialog:
Low (IIS Process): ASP pages run in INetInfo.Exe, the mai
....Read More |
Rating
|
|
|
Use Global.asa Metadata directive to access type libraries
|
Total Hit (2934) |
Most ADO statements require special constants to be passed as arguments to method calls, as in:
«Code LangId=5»
rs.Open "Authors", cn, adOpenForwardOnly, adLockReadOnly, adCmdTable
The above line is surely more readable than:
rs.Open "Authors", cn, 0, 1, 1
«/Code»
but for the fir
....Read More |
Rating
|
|
|
Use Response.IsClientConnected after long queries
|
Total Hit (3025) |
When you perform a complex and time-consuming query in your ASP program, you should periodically test whether the client is still connected, using the IsClientConnected method of the Response object, as in :
«Code LangId=5»
' a lenghty query here
' ...
' check whether the client is connected be
....Read More |
Rating
|
|
|
Use Server.HTMLEncode for strings stored in a database
|
Total Hit (2864) |
If your ASP pages display strings stored in database fields, you should always process the strings with the Server.HTMLEncode method, otherwise the string won't be displayed correctly in the user's browser if it contains characters that have a special meaning to HTML, such as the quote ("), the less
....Read More |
Rating
|
|