Thursday, April 3rd, 2008

JavaScript, C#, and ExtSharp

Category: .NET, Sencha

Colin Ramsay thinks that JavaScript and C# can be scarily similar as he shows an ExtJS example:


  1. var win = new Ext.Window({
  2.     title: 'Order Viewer', layout: 'border',
  3.     width: 500, height: 500,
  4.     modal: true, resizable: false, closable: false, draggable: false,
  5.     items: [ frm, lst ]
  6. });
  8. win.on('render', function() {
  9.     load(5);
  10. });
  1. var win = new Ext.Window{
  2.     Title = "OrderViewer", Layout = Layout.Border,
  3.     Width = 100, Height = 200,
  4.     Modal = true, Resizable = false, Closable = false, Draggable = false,
  5.     Items = new [] { frm, lst }
  6. };
  8. win.Render += delegate {
  9.     load(5);
  10. };

This works well for ExtJS since it is written in a style that leads itself to this similarity. Colin also points out ExtSharp, a project that lets you write your Ext application in C#:

I really love Ext but coding in javascript just gives me the chills. So I went out and found a way to use my favorite js library (Ext) and my favorite programming language (C#) at the same time. By using a project called Script# I am able to write C# code and have it converted into javascript, similar to GWT. Building on that, Script# also allows you to code against external APIs, but you need to create the types, methods, properties, etc. for everything in the javascript library. So what I did was write a little console app that parses all of the ExtJS source files extracting out the script comments and writing C# files for each class. The end result is a programmable C# API to access all of the Ext objects and I threw in a couple new things to make life a little easier.

Posted by Dion Almaer at 6:06 am
1 Comment

4.5 rating from 61 votes

1 Comment »

Comments feed TrackBack URI

I think that ExtJS took some heavy inspiration from the design of Windows Forms so this shouldn’t be a big surprise ;-).

Comment by posure — April 3, 2008

Leave a comment

You must be logged in to post a comment.