Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Mon May 05, 2008 5:37 am Post subject: HOWTO: Use ByRef event parameters in VBScript in an HTML/ASP page |
|
|
VBScript does not support ByRef parameters, so those events which use ByRef parameters to pass back information to FileView do not work. Thus, the following VBScript code to do custom sorting does not work :
<SCRIPT LANGUAGE="VBScript">
Sub FileView1_OnCompareItems(Item1, item2, comparison)
' Sort items in ascending order of length of display name
c = len(item1.displayname) - len(item2.displayname)
comparison = c
end sub
Sub FileView1_OnBeforeColumnSort(columnName, columnIndex, sortType)
c = 3 ' custom sorting
sortType= c
end sub
</SCRIPT>
Instead of using the ByRef parameter, the information should be passed to FileView using the CurrentFolder property as follows :
<SCRIPT LANGUAGE="VBScript">
Sub FileView1_OnCompareItems(Item1, item2, comparison)
' Sort items in ascending order of length of display name
c = len(item1.displayname) - len(item2.displayname)
fileview1.CurrentFolder = "intprop:" + cstr(c)
end sub
Sub FileView1_OnBeforeColumnSort(columnName, columnIndex, sortType)
c = 3 ' custom sorting
fileview1.CurrentFolder = "intprop:" + cstr(c)
end sub
</SCRIPT>
Use the prefix "intprop:" for ByRef parameters of type 'integer' or 'long'; use "strprop:" for ByRef parameters of type 'string' (used in OnInitialize and OnGetInfoTip). Note that the prefix ("intprop:" or "strprop:") must be lowercase.
For boolean ByRef parameters, set the CancelEvent propperty to the desired value in the event handler as follows :
<SCRIPT LANGUAGE="VBScript">
Sub FileView1_OnItemDblClick(Item1, x, y , Cancel)
' Cancel default action of double-clicked item
fileview1.CancelEvent = True
end sub
</SCRIPT> |
|