Exactly one year ago, I first announced my Script# project. Script# is a tool that brings (or attempts to reuse) the c# programming and tooling experience to create a more productive approach to script authoring, especially when you're writing script frameworks or libraries.
So it's a nice (ok I admit, sort of planned) coincidence that today, I am releasing another significant release with some key functionality added: support for ASP.NET AJAX. I am willing to bet that this will be of interest to a number of folks! Specifically, this means that there is a mode in the compiler that allows you to write script that only depends on MicrosoftAjax.js rather than on my custom Script# runtime/framework. While I certainly hoped that the ASP.NET AJAX framework itself would have been written in Script# (it can be... the compiler supports it, but it isn't, simply because the compiler wasn't ready early enough in the product cycle), it doesn't mean that you can't use this approach for your own client script libraries.
Head over to the Script# project page for full details about what changed this release, and to download the bits. I have put together a little video just under 10 minutes, that demonstrates how I might write a textbox Watermark behavior in ASP.NET AJAX using Script#.
(Double-click to view in full-screen mode)
I tried to tie in a number of benefits of Script# into this little demo. It is quite natural to think in terms of intellisense, compile-time error checking, and a hands-down better OOP syntax than any alternative script pattern that simulates OOP can provide, and these are certainly key to bringing a lot of productivity. However, the list of benefits really don't stop there. Various features of the IDE such as code snippets and refactoring and an msbuild-based project system can be leveraged as well. The familiar c#-style doc-comments can be used to produce actual documentation, or they be incorporated into the class browsing experience within .NET Reflector like I did in the video. In fact, the very possibility of browsing assemblies in a rich class browser aids the process of discoverability...
Here is the c# code itself for the watermark behavior from the demo...
using System;
using System.DHTML;
using Sys;
using Sys.UI;
namespace MyControls {
/// <summary>
/// A behavior to add watermarking to a textbox.
/// </summary>
public class Watermark : Behavior {
private string _watermarkText;
private string _watermarkCssClass;
private DomEventHandler _focusHandler;
private DomEventHandler _blurHandler;
public Watermark(TextElement e) : base(e) {
}
public string WatermarkText {
get {
return _watermarkText;
}
set {
_watermarkText = value;
}
}
public string WatermarkCssClass {
get {
return _watermarkCssClass;
}
set {
_watermarkCssClass = value;
}
}
public override void Dispose() {
DomEvent.RemoveHandler(Element, "focus", _focusHandler);
DomEvent.RemoveHandler(Element, "blur", _blurHandler);
base.Dispose();
}
public override void Initialize() {
base.Initialize();
ShowWatermark();
_focusHandler = OnFocus;
_blurHandler = OnBlur;
DomEvent.AddHandler(Element, "focus", _focusHandler);
DomEvent.AddHandler(Element, "blur", _blurHandler);
}
private void HideWatermark() {
TextElement textElement = (TextElement)Element;
if (textElement.Value == _watermarkText) {
textElement.Value = "";
DomElement.RemoveCssClass(textElement, _watermarkCssClass);
}
}
private void OnFocus(DomEvent e) {
HideWatermark();
}
private void OnBlur(DomEvent e) {
ShowWatermark();
}
private void ShowWatermark() {
TextElement textElement = (TextElement)Element;
if (textElement.Value == "") {
textElement.Value = _watermarkText;
DomElement.AddCssClass(textElement, _watermarkCssClass);
}
}
}
}
Looking back over the past year, it has been great to see the positive feedback and interest, whether it came in the form of comments, emails or bug reports. I thought I'd share a few key interesting highlights. Originally Script# started as a means to writing functionality for AJAX applications against the DHTML DOM, and was fairly experimental in terms of whether it would scale at all. Over the year, it has grown to support Silverlight (yes, beta 1 is now supported), and the Virtual Earth map control. Furthermore, it supports out-of-the-browser scripting scenarios by supporting the Sidebar gadgets API, the IE7 RSS Feeds API, and the File System Object API as well. The full Script# framework itself has been written using Script#. Various groups within Microsoft (such as Messenger, Windows Live and Office) are now looking to Script# as a key aspect of their script development process, which has been a great source of validation, and continous improvement. I wrote a Thinkweek paper on Script# last winter, and it was quite well-received by BillG and his technical staff. However, perhaps the most personal metric that I've been able to relate to is that I've been able to switch over to using Script# when it comes to any form of serious scripting beyond basic prototyping/experimenting - for example my UpdateControls suite, and for my PhotoViewer and PhotoMap prototypes.
Going forward, the plan is to continue to incrementally improve the project based on feedback I receive. There are a few significant feature plans I have in particular around support for generics, and static linking on the compiler end, and things like RichTextBox, drag and drop, and a few Silverlight-related scenarios on the frameworks end of things. A longer list of items in the roadmap, along with lots more conceptual material, is listed in the Script# readme.
Posted on Monday, 5/21/2007 @ 6:24 PM
| #
Script#