Script#: The .NET Response to the Google Web Toolkit

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Script#: The .NET Response to the Google Web Toolkit - Presentation Transcript

    1. Script# - the .NET response to Google Web Toolkit Gojko Adzic http://gojko.net [email_address]
    2. Why should you care?
      • A much more productive way to write and maintain complex JavaScript code
        • Compile-time consistency check
        • Refactoring support
        • Full Intellisense for DOM and your own JS classes
        • Lots of other VS IDE benefits
      • Free (not opensource, though)
    3. What Script# is not
      • It does not hide browser complexity
      • It does not abstract away JS peculiarities
      • It is not a general-purpose .NET to browser converter
      • It is not a widget/effect library (it has some, but not nearly like GWT)
    4. Under the hood
      • Compiles C# into JS directly
      • Replacement for System namespace, a mashup of .NET and JS
        • Sscorlib.dll in C# for Intellisense,
        • sscorlib.js in the browser
        • sscompat.js provides cross-browser compatibility
      • System.DHTML.Document, System.Script System.DHTML.Window link to the environment
    5. A very simple example
      • Script# library project
      • Compile C# into javascript
      • Execute from HTML
        • namespace.class used to instantiate objects
      • If you do the web site by hand, don’t forget sscompat.js!
    6. Visual Studio Integration
      • Project templates for class libraries and web sites
      • C# editor for scriptlets (has some bugs, though)
    7. MSBuild Integration
      • ScriptSharp target does the job for you <Import Project=&quot;$(ProgramFiles) StuffScriptSharpv1.0 Stuff.ScriptSharp.targets&quot; />
      • Remember <NoStdLib>True</NoStdLib>
      • Automatically added by the VS ScriptSharp template
    8. Scriptlets
      • Script# webforms components
        • Add Script# assembly and page control to web.config
        • Use main() as an entry point to the component
      • No need to worry about script# initialisation
      • Put all scripts into App_Scripts folder (or use a VS template to create the project)
    9. AJAX support
      • Add <script type=&quot;text/javascript&quot; src=&quot;App_Scripts/ssfx.Core.Debug.js&quot; >
      • </script>
      • Use ScriptFX.Net. HTTPRequest for cross-browser compatible AJAX requests
      • Supports Script transport for Cross-Domain Ajax!
    10. Ajax/JSON
      • private void OnOKButtonClick(object sender, EventArgs e) {
      • Dictionary parameters = new Dictionary();
      • parameters[&quot;prefix&quot;] = _prefixTextBox.Text;
      • parameters[&quot;count&quot;] = 5;
      • _request = HTTPRequest.CreateRequest(&quot;CompletionList.ashx/GetItemsViaPost&quot;, HTTPVerb.POST);
      • _request.SetContentAsJSON(parameters);
      • _request.Invoke(new HTTPRequestCompletedCallback(OnRequestComplete), null);
      • }
      • private void OnRequestComplete(HTTPRequest request, object context) {
      • if (_request == request) {
      • string[] values = (string[])_ request.Response.GetObject() ;
      • _valuesLabel.Text = values.Join(&quot;, &quot;);
      • }
      • }
    11. Behaviours
      • Declaratively attach functionality to DOM elements
      • Taken from ASP.NET Ajax (Atlas)
      • Popups, watermark, autocomplete, overlay etc…
      • Not a lot of widgets, but you can use ExtJS with ExtSharp!
    12. More advanced options
      • FxCop code analysis
      • Unit testing should follow soon
      • ASP.NET Ajax instead of sscorelib
      • Some silverlight support
      • MSN Messenger APIs
      • Facebook client API
      • Sidebar Gadgets
    13. Quirks: Namespace references
      • Does not work:
        • DOMElement runner= System.DHTML. Document.GetElementById(
        • runnerElementId);
      • Works:
        • Using System.DHTML;
        • DOMElement runner= Document.GetElementById(runnerElementId);
    14. Quirks: Compilation issues
      • VS New class wizard adds System, System.Data and System.Xml references
        • Script# compilation breaks as a result
      • Does not resolve indirect module dependencies
      • Nested namespaces not supported
    15. Quirks: 0 and null comparisons
      • if (something == null) and if (something == 0) compiled into if (!something)
      • Try this:
      • Number a = null;
      • if (a == 0)
      • Script.Alert(&quot;I shouldn't be seeing this???&quot;);
      • Number b = 0;
      • if (b == null)
      • Script.Alert(&quot;I shouldn't be seeing this either???&quot;);
    16. Quirks: Scriptlets
      • Scriptlet tag has to be inside a form tag
        • If not, nothing happens, but you don’t get an alert
      • Inline Scriptlets use ScriptletArguments, pre-compiled ones use Dictionary
    17. Quirks: Events
      • DOMEventHandler expects void() delegate
      • Use Window.Event.ReturnValue to return false from an event
    18. What’s good?
      • Working with complex JS files is much very productive
      • VS integration
      • MSBuild integration
      • Basic Documentation is great
    19. What’s not so good?
      • Some unintuitive mismatch between C# and JS – type conversions, 0 and null…
      • Advanced stuff not documented that well
        • See the samples zip in the distribution!
      • Still not opensource
    20. Where next?
      • http://gojko.net
      • http://projects.nikhilk.net/ScriptSharp/
      • http://code.google.com/p/extsharp/
      • http://www.codeplex.com/JQuerySharp
    21. What next?
      • Dependency Injection with Castle – Oct 23 rd
      • Asynchronous Enterprise Applications with NServiceBus – Nov 27 th
      • TDD with .NET – Dec 17 th
      • ALT.NET Community evening – Jan 13th

    + guest24aa8dguest24aa8d, 2 years ago

    custom

    1075 views, 2 favs, 0 embeds more stats

    Script# is a free .NET tool that converts C# into J more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1075
      • 1075 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 8
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags