Activate your free membership today | Log-in

Thursday, April 3rd, 2008

JavaScript, C#, and ExtSharp

Category: .NET, Ext

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

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

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
4 Comments

++++-
4.5 rating from 58 votes

4 Comments »

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

Thanks. Good article.

Comment by ermenisoykirmi — May 30, 2008

Interesting Article, thanks Armenian Genocide , great information and research.

Comment by ArmenianGenocide — June 8, 2008

Gucci, on the othergucci handbags hand, presents us with popularity for all gucci diaper bagsthe wrong reasons. In fact, he is currently grounded in his home state of Georgia duefake gucci handbags to legal woes, according to The Associated Press. And unless the bandana-bearer’s albumgucci wallets for men represents a total departure from his current persona, ’s drug references, rampant materialism, brushes with the law and cheap wedding dressesspeak-and-spell rhymes make him a poster child for what ails mainstream rap.

Comment by wuwei — December 16, 2009

Leave a comment

You must be logged in to post a comment.