Thursday, December 15, 2005

"ActiveX Scripting WebPart" for SharePoint technologies

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

http://blogs.msdn.com/smourier/archive/2003/07/13/181836.aspx

Comments and questions are welcome!

Simon.

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

Installation:
--------------------------------------------------------------------------------
The WebPart can be installed using SharePoint standard deployment tools:

"%CommonProgramFiles%\Microsoft Shared\web server extensions\60\BIN\stsadm"
-force -o addwppack -filename ActiveScript.Web.UI.cab
-url
http://serverNameGoesHere

Or (GAC installation)

"%CommonProgramFiles%\Microsoft Shared\web server extensions\60\BIN\stsadm"
-force -o addwppack -filename ActiveScript.Web.UI.cab
-globalinstall -url
http://serverNameGoesHere

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


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

Legend:
+: 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)


2 Comments:

Blogger IsabellaWilliams said...

I believe there is no http://startso11.info/szkolenia+j%C4%99zykowe+dla+firm+%C5%82%C3%B3d%C5%BA.html 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 http://startso11.info/wwww.foczkiro.pl.html from those of neurotic patients may be rejected without comment.. [2] The words from and to http://startso11.info/lublin+plaza.html channels in the next sentence is a short summary of the passage in the original.. The boats generally start about this time http://startso11.info/kody+do+radi.html in the morning, and I will go and see about it.. They both stopped stock http://startso11.info/www.t.a.t.u.be.html 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 http://startso11.info/WWW.AP.html 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 http://startso11.info/w.orange.pl.html 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 http://startso11.info/ochrona+wynagrodzenia+za+prac%C4%99.html prosaic facts--he had his own theory of the case, which no mere evidence could gainsay.. Human life should not be considered as http://rebestal.info/budownictwo.html the proper material for wild experiments.. Freud's theories are http://startso11.info/www.brzesko.zszp2..html anything but theoretical.. And so, over the gleaming sea which he had watched so long, and which seemed thus to reward his patient http://startso11.info/odliczanie+podatku+VAT.html gaze, came his bride that sunny morning.. No shyness, nor awkwardness, nor silence, could separate me from those who looked lovely http://rebestal.info/bobcat.html as lilies to my illuminated eyes.. My wife leads me a little way along http://rebestal.info/biglea.html 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 http://startso11.info/lubin.pl.html up, and with a bound dashed along the tow-path.. The former issue we conceive http://storyah44.info/reduktory+gazu.html 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 http://startso11.info/laneta.html she intended, for the benefit of her correspondent.. Before leaving these infantile dreams, which are obviously unrealized desires, we must not fail to http://startso11.info/www.gimzuki.pl.html 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 http://startso11.info/www.auto.24.html a little wrinkle above her nose.. The child having been shaken up http://startso11.info/neatmovies.com.html hard (two or three others helping Christopher), rubbed his eyes and began to whine.. ceases to occupy the http://startso11.info/ogniomur.html 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