Tuesday, July 13, 2004

ActiveX Scripting WebPart for SharePoint technologies

ActiveX Scripting WebPart for SharePoint technologies

"...This is a generic sample 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 & "
"
writer.Write "Date: " & Now
End Sub

...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 declaration:

Context.Response.Write Context.User.Name

Or it can be placed inside predefined "Emulated" function. ..."

Pretty cool (and could be pretty scary?)

This is a scripting scriptable webpart. Meaning that once the Part has been added to a page, you can "edit" the part, adding VBScript/JScript code to be run on the server.

Sounds like something cool to play with. :)


(via his other blog @ Simon Mourier's WebLog)

No comments: