Thursday, December 15, 2005

"ActiveX Scripting WebPart" for SharePoint technologies

This is the new home of ActiveX Scripting WebPart that was previously located at

Comments and questions are welcome!


Yes, this sounds heretic, and it probably is :-) This is a generic sample (use it at your own risk :-) WebPart for SharePoint technologies (means it works for Microsoft Windows SharePoint Services as well as Microsoft SharePoint Portal Server 2003) that runs an ActiveX Scripting code on the server.
By default, VBScript and JScript (a.k.a JavaScript) are supported on decent Windows installations, but nothing prevents you from using Python, Perl or other languages that have an ActiveX Scripting existence. Here is an example of such a code (in VBScript) that displays the user name and the current date:

Sub Render(writer)
writer.Write "User: " & Context.User.Name & "<br>"
writer.Write "Date: " & Now
End Sub

Binaries and Source code can be downloaded from here

The WebPart can be installed using SharePoint standard deployment tools:

"%CommonProgramFiles%\Microsoft Shared\web server extensions\60\BIN\stsadm"
-force -o addwppack -filename

Or (GAC installation)

"%CommonProgramFiles%\Microsoft Shared\web server extensions\60\BIN\stsadm"
-force -o addwppack -filename
-globalinstall -url

The WebPart caches a compiled version of the scripts. If you want to disable this cache, just add the following to your web.config:
<add key="ScriptCachingMode" value="disabled" />

Using the standard WebPart modification tools provided by the SharePoint WebPart Framework (Design Page, Browse, Modify, ToolPane, ...), you can switch the WebPart from Edit Mode to Run Mode. In Edit mode, you can type the script code directly into the provided TextArea.
This script code can be put in the main procedure (the one that is not inside a declared procedure, sub or function). In this case, it will run probably at Page initialization. For example, the following script code will render the current user's login name *before* the first <html> declaration:

Context.Response.Write Context.User.Name

Or it can be placed inside predefined "Emulated" function. Supported emulated functions prototypes are (the syntax here is in VBScript):

Sub OnInit()
' Code put here will run in the OnInit method
' of the ActiveX Scripting WebPart
End Sub

Sub OnLoad()
' Code put here will run in the OnLoad method
' of the ActiveX Scripting WebPart
End Sub

Sub OnPreRender()
' Code put here will run in the OnPreRender method
' of the ActiveX Scripting WebPart
End Sub

Sub Render(writer)
' Code put here will run in the Render method
' of the ActiveX Scripting WebPart
' The Writer object has only one Write(object obj) method
' see the example at the beginning
End Sub

Sub OnUnload()
' Code put here will run in the OnUnload method
' of the ActiveX Scripting WebPart
End Sub

"Emulated" ASP.Net Object Model:
As already demonstrated before, the script code recognizes one "named object" (in ActiveX Scripting terminology) which is "Context" (sounds familiar?). From this context object, the ActiveX Scripting WebPart provides limited support for an "emulated" ASP.Net HttpContext object model. Please consult ASP.Net documentation for details on the following properties and methods.

+: Class
R: Read Only property
RW: Read Write property
M: Method):

+ Context
+ Cache
M void Insert(string key, object value)
M object Get(string key)
R int Count
M object Remove(string key)

+ Request
R int ContentLength
R string CurrentExecutionFilePath
R bool IsAuthenticated
R bool IsSecureConnection
R string Path
R string PathInfo
R string PhysicalApplicationPath
R string PhysicalPath
R string RawUrl
R string RequestType
R int TotalBytes
R string UserHostAddress
R string UserHostName
M void ValidateInput()
M void SaveAs(string filename, bool includeHeaders)
M void MapPath(string virtualPath, string baseVirtualDir,
bool allowCrossAppMapping)
R string UserAgent
R string HttpMethod
R string ContentType
RW Encoding ContentEncoding
R string ApplicationPath
R string FilePath

+ Response
RW bool SuppressContent
R bool IsClientConnected
RW bool Buffer
RW bool BufferOutput
RW string StatusDescription
RW string Charset
RW string Status
RW string CacheControl
RW string RedirectLocation
RW int Expires
RW DateTime ExpiresAbsolute
RW string ContentType
RW Encoding ContentEncoding
RW int StatusCode
M void AddHeader(string name, string value)
M void AppendHeader(string name, string value)
M void AppendToLog(string param)
M void ApplyAppPathModifier(string virtualPath)
M void BinaryWrite(byte[] buffer)
M void Pics(string value)
M void SetCookie(string name, string value)
M void TransmitFile(string filename)
M void Clear()
M void ClearContent()
M void ClearHeaders()
M void Close()
M void End()
M void Flush()
M void Redirect(string url, bool endResponse)
M void Write(object obj)

+ Server
R string MachineName
R int ScriptTimeout
M void ClearError()
M object CreateObject(string progID)
M object CreateObjectFromClsid(string clsid)
M string HtmlDecode(string s)
M string HtmlEncode(string s)
M string MapPath(string path)
M void Transfer(string path, bool preserveForm)
M string UrlDecode(string s)
M string UrlEncode(string s)
M string UrlPathEncode(string s)

+ Session (no method implemented so far..., coding anyone ?)

+ Trace
R TraceMode TraceMode
R bool IsEnabled
M void Write(string message)
M void Warn(string message)

+ User
R string Name
R string AuthenticationType
R bool IsAuthenticated
M bool IsInRole(string role)


Blogger IsabellaWilliams said...

I believe there is no formal rule permitting strangers to speak; but no one objected.. The objection that no deduction can be drawn regarding the dreams of healthy persons from my own dreams and from those of neurotic patients may be rejected without comment.. [2] The words from and to channels in the next sentence is a short summary of the passage in the original.. The boats generally start about this time in the morning, and I will go and see about it.. They both stopped stock still; then, seeing that it was too late to retreat, both laughed and advanced.. Now and then a symbol in the dream content may have to be interpreted not symbolically, but according to its real meaning; at another time the dreamer, owing to a peculiar set of recollections, may create for himself the right to use anything whatever as a sexual symbol, though it is not ordinarily used in that way.. Now, William, said his host, I understand perfectly your feeling about boats, and what I wish to prove to you is that it is a feeling without any foundation.. He remembered his own power with a jury; his vanity and his chivalry alike approved of this heroic method; he was bound by the prosaic facts--he had his own theory of the case, which no mere evidence could gainsay.. Human life should not be considered as the proper material for wild experiments.. Freud's theories are anything but theoretical.. And so, over the gleaming sea which he had watched so long, and which seemed thus to reward his patient gaze, came his bride that sunny morning.. No shyness, nor awkwardness, nor silence, could separate me from those who looked lovely as lilies to my illuminated eyes.. My wife leads me a little way along the street up to the little house, and pushes in the door, and then I slip quickly and easily into the interior of a courtyard that slants obliquely upwards.. Then, impressed with a horror of the glaring apparition, he gathered himself up, and with a bound dashed along the tow-path.. The former issue we conceive as follows: It diffuses its energy through all the association paths emanating from it, and throws the entire chain of ideas into a state of excitement which, after lasting for a while, subsides through the transformation of the excitement requiring an outlet into dormant energy.. Yet she could not help becoming somewhat interested in the spelling-school, and after it was over found she had not stored up half as many of the schoolmaster's points as she intended, for the benefit of her correspondent.. Before leaving these infantile dreams, which are obviously unrealized desires, we must not fail to mention another chief characteristic of dreams, one that has been long noticed, and one which stands out most clearly in this class.. We must have money, said Miss Lydia, with a little wrinkle above her nose.. The child having been shaken up hard (two or three others helping Christopher), rubbed his eyes and began to whine.. ceases to occupy the energy, therefore consists in the fact that the unconscious excitations liberate such an affect as--in consequence of the repression that has previously taken place--can only be perceived as pain or anxiety...

10:19 PM

Blogger shdh said...

If you are cheap wow gold trying any unknown cheats to earn gold, you would cheapest wow gold face some problem and your account will be black out. So don't try to wow gold cheap find cheats instead try to wow7gold follow the guideline of world of warcraft. These tips could euwowgoldwork as gold cheat and can help a lot to earn gold and money. World of Warcraft is the most exiting online game and while Playing the game most of the players struggle ogpal to earn a lot of gold.

Most of the players World Of Warcraft Goldtry search cheat code for this game to earn gold. This article will help xowow you a lot to earn more and more gold.The best way to earn gold in this online game is by going through the guidelines wow gold for saleand other information about wowgold4europethe game that are available on the internet .

9:58 AM


Post a Comment

<< Home