Let me know your questions for Scott Guthrie and the ASP.NET Team @devconnections

I’m going to be at DevConnections this year to deliver a session on Microsoft Ajax with Jim Wang and also chair a panel with Scott Guthrie and members of the ASP.NET Team.  First of all here are details on the invitation:

Join us for a technical question and answer session with Scott Guthrie and members of the ASP.NET team on November 10th 2009 from 6:15 PM - 8:15PM at the ASP.NET Connections conference in Las Vegas. This is your chance to meet face to face with the people working on ASP.NET, give feedback and receive guidance. Attendance is limited so be there early and ask for details at the registration desk. We will have pizza and beverages.

I’ll be taking questions from the audience but if you can’t make it to Las Vegas and want to pose a question to Scott and the team feel free to leave me a comment on this post or hit me on twitter @jsenior!

See you there!



Tags:

How the Script Loader in the Microsoft Ajax Library will make your life wonderful

Everyone in the Microsoft Ajax team has a favorite feature, the CDN, jQuery Integration, and mine happens to be the Script Loader. I’m fond of it because it has some really cool features that aid the performance of my web application and take away much of the headache associated with organizing and loading any scripts that I use either from Microsoft, my own application or indeed a third party library like jQuery. The headache I’m referring to can be best characterized in the example below where I am loading scripts needed to use controls from the Ajax Control Toolkit (ACT) and the various components of the Microsoft Ajax Library. There are multiple scripts required and prior to the Script Loader I would be bringing them in all manually and having to worry myself with loading them in the right order. Not fun.

 

  1. // Microsoft Ajax Library scripts
  2.     <script type="text/javascript" src="../Scripts/MicrosoftAjax/MicrosoftAjaxCore.js"></script>
  3.     <script type="text/javascript" src="../Scripts/MicrosoftAjax/MicrosoftAjaxComponentModel.js"></script>
  4.     <script type="text/javascript" src="../Scripts/MicrosoftAjax/MicrosoftAjaxSerialization.js"></script>
  5.     <script type="text/javascript" src="../Scripts/MicrosoftAjax/MicrosoftAjaxGlobalization.js"></script>
  6.     <script type="text/javascript" src="../Scripts/MicrosoftAjax/MicrosoftAjaxTemplates.js"></script>
  7.  
  8.     // ACT Controls
  9.     <script src="../Scripts/ACT/ACTRegisterExtended.js" type="text/javascript"></script>
  10.     <script src="../Scripts/ACT/ACTWatermark.js" type="text/javascript"></script>
  11.     <script src="../Scripts/ACT/ACTExtenderBase.js" type="text/javascript"></script>
  12.     <script src="../Scripts/ACT/ACTCommon.js" type="text/javascript"></script>

This can all be made better – let’s find out how by starting at the beginning with start.js.

Getting started with the script loader

Start.js is your friend. It contains the Script Loader which is super small and knows about all the scripts of the Microsoft Ajax Library, some of which are listed in the above sample. You include it just as you would any other script like so:

  1. <script type="text/javascript" src="../scripts/start.js"></script>

It’s also available via our brand spanking new, smoking fast Microsoft Ajax CDN so your customers will get blisteringly fast script downloads wherever they are in the world. ScottGu’s got more info on the CDN here.

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/beta/0910/Start.js"></script>

Now that you’ve got the Script Loader bootstrapped it’s time to “harness the power of the atom” (Scott Hanselman’s favorite saying at the moment) and start loading scripts into your application. The Script Loader allows you to load libraries and scripts into your application without having to worry about where the code file is. Now this is where it gets sexy (yes JavaScript can be sexy). In the following example I want to use the dataView control and the ApplicationServices script (both included in Microsoft Ajax Library) so I tell the Script Loader to get them ready for me using “Sys.require”:

  1. <script src="../Scripts/MicrosoftAjax/start.js" type="text/javascript"></script>
  2. <script type="text/javascript">
  3.  
  4.     // Load required scripts for DataView client control, using script Loader
  5.     Sys.require([Sys.components.dataView, Sys.scripts.ApplicationServices], function () {
  6.  
  7.         // do some stuff with dataView and Application Services
  8.  
  9.     });
  10.  
  11. </script>

Once the Script Loader fetches them (in parallel) and executes them it checks if the DOM is ready and then calls the function I’ve specified in the second parameter of Sys.require. On a side note, we can also bring in jQuery by adding Sys.scripts.jQuery to the array.

Let’s take it further by considering a common scenario where I have created a custom script for my application. The script is only needed when a user clicks a certain button though, so we’re going to register it with the Script Loader but only execute it on-demand when (this is an example of what we call “lazy loading”):

  1. <script src="../Scripts/MicrosoftAjax/start.js" type="text/javascript"></script>
  2. <script src="../Scripts/RegisterMyAppScript.js" type="text/javascript"></script>
  3.  
  4. <script type="text/javascript">
  5.  
  6.     function useMyCustomScript() {
  7.  
  8.         Sys.require(Sys.scripts.myAppScript, function () {
  9.             // Use my custom script
  10.         });
  11.  
  12.     }
  13.             
  14. </script>
  15.  
  16. <input type="button" onclick="useMyCustomScript()" value="Click me"/>

“But wait”, I can hear you say, “what is that extra script we reference – “RegisterMyAppScript.js”? Good question – that’s where we define our script and any other scripts that it depends on.

Let’s be definitive

Within RegisterMyAppScript.js we use the Script Loader’s “defineScripts” method to make it aware of the location of our script and any dependencies that it may have on other scripts:

  1. Sys.loader.defineScripts({
  2.         releaseUrl: "%/../CustomScripts/{0}.js",
  3.         debugUrl: "%/../CustomScripts/{0}.js"
  4.     },
  5.         [
  6.             { name: "myAppScript",
  7.                 executionDependencies: ["ApplicationServices"],
  8.                 isLoaded: !!(window.My && My.Scripts && My.Scripts.TheScript)
  9.             }
  10.         ]
  11.     );

First we specify a release and debug URL and depending on how we’ve setup the loader it will use a minified version or a version with comments and intellisense (we’ll get into that later). Then we pass a parameter to defineScripts that provides the information about the different scripts we want to register – in our case “myAppScript”. For each script we specify the name (filename without the file extension) its execution dependencies and an isLoaded test that we use to check if the script has already been loaded (we don’t want to load it again!)

If this were a custom control we were loading then we could also tell the Script Loader under which namespace our behaviors are loaded.

Now we can let the Script Loader worry about the fact that my custom script requires ApplicationServices from the Microsoft Ajax library and it will load all the required scripts in parallel, maximizing performance whilst only executing them when they are ready.

Next we’ll look at what the actual custom script looks like.

Parallel Power with dependency management built in

In the past, loading scripts in sequence made sense when you had complex dependencies that tied the scripts together however this is not recommended practice if performance is important. Let us assume that both having modular code (dependencies) and good performance is important to you. Whilst browsers have been able to load two scripts in parallel for some time, modern browsers let you load many at once but this in itself can raise a couple of problems. Firstly, we have a “race condition” where Script A is racing against Script B to be loaded and executed. When there are dependencies between A and B and the dependent script loads first (for whatever reason) your code will break because it is expecting a symbol to be present that has yet to be loaded and executed by the browser. Secondly, only modern browsers allow us to load more than two scripts in parallel (there are some hacks you can do but let’s assume we’re not using them), so if we have a large collection of scripts with dependencies we will still be waiting an undesirable length of time.

The Script Loader allows us to download multiple scripts in parallel whilst managing all their dependencies and making sure that we only execute the scripts once a dependency is satisfied.

There’s one more question that needs answering though. How do we load the scripts, like RegisterMyAppScript.js, without executing them automatically? We solve this problem by wrapping the script in an execute function and then check to see if the Script Loader is ready (loaded). If it’s ready to rock then we then call registerScript, passing in the name of the component and the execute callback function. Now the loader knows that this is the script that must be called when all its dependencies are in place – and that execute is the function to make this happen.

  1. (function() {
  2.         function execute() {
  3.             // .. script content ..
  4.         }
  5.      
  6.         if (window.Sys && Sys.loader) {
  7.             Sys.loader.registerScript(“myAppScript”, null, execute);
  8.         }
  9.         else {
  10.             execute();
  11.         }
  12.     })();

You’ll notice that if the Script Loader is not there (for whatever reason) then we just go ahead and execute the script anyway – with this we are preserving the original functionality of the script.

Power to the developer

A lot of developers are scared by JavaScript development. However, more recently with the introduction of libraries like Microsoft Ajax Library and jQuery as well as better intellisense support and browser debugging there is no longer much of a reason to hide behind the cushions. Remember earlier on where we specified a release and debug version of the scripts? The Script Loader has a property we can set to enable a debug mode which when we are running our scripts and stepping through them using our favorite browser plugins is really useful. When set to true the loader uses the version which is not minified and has comments so we can figure out where our script is going wrong.

  1. Sys.debug = true;


Summary

That’s it for now but there is a bunch more features in the Script Loader that I will cover off in future blog posts, including:

  • Lazy Loading
  • Intellisense in Visual Studio
  • How the loader does the ordering of scripts
  • Handling DOM ready events etc

In this blog post we’ve seen how script loading and management of execution is made easier using the Script Loader from the Microsoft Ajax Library as well as covering off how we handle dependencies between different scripts and debugging.

To find out more about what’s in the Microsoft Ajax Preview 6 release check out the following resources and be sure to come to Microsoft PDC where we’ll be doing sessions on the new stuff!

Tags:

Am I the only one buying magazines? Am I a renaissance geek?

Jon Udell’s Innovators show this featured Hugh McGuire who is launching a new project, BookOven, designed to aid collaboration between authors and readers during a book’s creation.

His post got me thinking about how since being in the US I have spun up two subscriptions to magazines where prior to my move I had consumed all my content online.  The two magazines are Wired and GQ and the thing that drew me to their subscription was the price - $10 for a year long subscription.  This to me, was astonishingly cheap and given that I’ve been an avid reader online I felt it was my duty to give back in this small way.

Living and working in Seattle amongst so many technophiles and geeks is always fascinating no more so than on the public bus - the 545, that ferries us all from Seattle to Redmond.  Once onboard one can’t help but study the habits of individuals.  There are laptops and devices being used in most seats, grabbing the free wifi, whilst there are a few of us who are living the renaissance and reading – shock horror - books and magazines. 

There’s something romantic and soothing being offline, amongst pages you can feel and turn, that don’t make your eyes tired.  There’s no temptation to check your email with the gold Outlook logo staring you down – it’s nice. 

I consider it the perfect start to my day and it’s all thanks to a $10 a year subscription to a medium that is supposedly doomed.  It’s hard to believe that given the small amount there’s not a bigger draw to magazine subscriptions.

Anyway, I hope you enjoyed this little thought bubble, reading it online on your screen, for free.  Happy Sunday.

(Photo thanks to www.busdude.com and his final collection of bus photos from the Seattle area.)

Tags:

Hey Websites: Get your Bing on with a little bit of MS Ajax and jQuery to make it slick

As well as releasing Web Platform Installer Version 2, we’ve also launched a bunch of Web App Toolkits that show you how to accomplish common web development tasks with small sample apps.  We provide all the source code so that you can go from 0 to F5 in less than 60 seconds.  Check out the Channel 9 interview I’ve done with Jonathan on Web App Toolkits! The scenarios we’ve covered with the first round of Web App Toolkits include:

One of the Web App Toolkits that was close to my heart (other than the Social one, of course) was the Bing Web App Toolkit which shows how you can bring search a Web App Toolkit using the Bing API 2.0.  Aside from the cool Web Controls that we’ve supplied you get a sample app where we spice up the UI using JavaScript and the MS Ajax Library to to asynchronous calls back to the Bing API to get the results I need.

Then I took the Web App Toolkit one step further and added some jQuery UI effects to add that next layer of slickness.  Here are the JavaScript references for both Microsoft Ajax and jQuery playing nicely alongside one another.

image

In this example we have Client Templates and the MS Ajax dataview handling all the data fetching and binding whilst the jQuery UI plugin takes care of the UX.

The jQuery UI elements I added included a lightbox from Leandro’s cool website, for the images that are returned from Bing, and qTip from Craigsworks.com which provide some nice tooltip effects to display extra search information returned from Bing. 

Bringing these into my project is so easy. For the Lightbox plugin all you need to do is assign the repeating element in the template a class of “lightbox”.  In this example it’s the anchor element (see below) and the jQuery UI plugin will do the rest.

image 

It’s a similar story for the tool tips where I just drop in a class of “tooltip” into the anchor element and the jQuery UI plugin does the rest.

image

I’ve posted the code for this app on my Skydrive account – feel free to download it below:

 



Tags:

Keyboard Shortcuts in Hotmail (now with Yahoo Mail and Gmail modes)

image

Stumbled across a nice feature in Hotmail today.  You can change your keyboard shortcuts in Hotmail to use either Hotmail/OWA mode or for users who are more familiar with Yahoo Mail or Gmail there is an option for them too.  The always useful help library for Windows Live has a full list of keyboard shortcuts for all modes which I’ve copied and pasted in all its glory here for your viewing pleasure:

Keyboard shortcuts

Keyboard shortcuts can save you time when you use Windows Live Hotmail.

To

Press

Delete a message

Delete

Create a new message

Ctrl+N

Send a message

Ctrl+Enter

Open a message

Ctrl+Shift+O

Print a message

Ctrl+Shift+P

Reply to a message

Ctrl+R

Reply all to a message

Ctrl+Shift+R

Forward a message

Ctrl+Shift+F

Save a draft message

Ctrl+S

Mark a message as junk

Ctrl+Shift+J

Mark a message as read

Ctrl+Q

Mark a message as unread

Ctrl+U

Move to a folder

Ctrl+Shift+V

Open the next message

Ctrl+.

Open the previous message

Ctrl+,

Close a message

Esc

Search your e-mail messages

/

Check spelling

F7

Select all

S then A

Deselect all

S then N

Go to the inbox

G then I

Go to your People page

G then P

Go to your Calendar

G then C

Go to Messenger (this will open Windows Live Messenger from within Hotmail)

G then M

Go to your Home page

G then H

Go to your Drafts folder

F then D

Go to your Sent folder

F then S

If you're more familiar with Gmail or Yahoo! keyboard shortcuts, you can use these in Hotmail too. If a cell is empty, there is no corresponding keyboard shortcut in Gmail or Yahoo!.

To

Gmail shortcut

Yahoo! shortcut

Delete a message

#

Delete

Create a new message

C

N

Send a message

 

Alt+S

Open a message

O

 

Print a message

 

P

Reply to a message

R

R

Reply all to a message

A

A

Forward a message

F

F

Save a draft message

Ctrl+S

Ctrl+S

Mark a message as junk

!

 

Mark a message as read

Ctrl+I

K

Mark a message as unread

Shift+U

Shift+K

Move to a folder

 

D

Open the next message

N

Ctrl+.

Open the previous message

P

Ctrl+,

Close a message

U

Esc

Search your e-mail messages

/

S

Check spelling

   

Select all

* then A

 

Deselect all

* then N

 

Go to the inbox

G then I

M

Go to your People page

G then C

 

Go to your Calendar

   

Go to Messenger (this will open Windows Live Messenger from within Hotmail)

   

Go to your Home page

   

Go to your Drafts folder

G then D

 

Go to your Sent folder

G then T

 

Tags:

I love the smell of innovation in the morning

photo (4) Innovation was rife and developers were coding like demons possessed at the Startup Weekend in Redmond this weekend as groups took ideas from whiteboard to demoware in a coffee fuelled 54 hours.  It was great to see a wide range of platforms and technologies in play from ASP.NET MVC web apps, AJAX and Silverlight RIAs and mobile clients on WinMo, Palm and iPhone. 

The big winner was an app called “Search Kick”, a contextual search app, who walked away with a cool $5000 in cash and a potential investment in the future from H-Farm, also for $5000.  Also in the top three was iPhone app, “Learn That Name”, a cool bit of software that helped you put names to faces.  The majority of apps (15 of 16) were being built on the Microsoft Web Platform – and everyone had a copy of the Web Platform Installer spun up at least once during the day!

The thing that made me smile was seeing so many passionate, creative people coming together as strangers to create cool software on different platforms, using different tools.  The teams had a great time doing so and the real winner was innovation and I’m really excited to see where these apps go as businesses.

My CTO Advice

Myself and Brian Gorbett were “CTOs for hire” and we had a blast brainstorming cool ideas with the teams and guiding them as they made decisions on which technologies to build on.  Here are my top tips that I was giving the startups during the weekend:

1. Leverage skills you have in your group

Everyone brings something unique to the table from database architecture, UX design to social media guru – delegate appropriately and get everyone working to their strengths – you are most effective that way.

2. Choose the right technology for the job

If you are building a table in your web app to show data, for heaven’s sake don’t use Silverlight – it’s overkill! Use HTML with some JavaScript from jQuery to make it slick and some client templating from ASP.NET AJAX Preview 4 to bring the the data from the server without refreshing the page.  Every technology has a time and place, don’t try and crowbar in a technology just because it’s cool – fit the problem to an appropriate technology.

3. Deliver something that pops

At these events it is easy to bite of more than you can chew.  Be aggressive but realistic and aim to deliver something within the time constraints.  It is far better to knock one feature out of the park than to deliver 10 half-assed features that fail to pop.

4. Watch the clock

Keep an eye on your time constraints and work in tight iterations.  The most successful teams were those that collaborated well and worked in hourly stints and then pulled together what they had done into one solution.

5. The Web Platform Installer is your best friend – use it

The Web Platform Installer is the quickest and easiest way to get a development rig up and running.  If ASP.NET is your thing or PHP gets you going you can get it all from server, through to database and tools.  The Web Platform Installer gives you everything you need on one hit without having to install everything separately.  Work smarter not harder – use the Web Platform Installer.

6. (Ab)use BizSpark

photo

Get Microsoft’s software.  Get startup advice.  Use our investor network.  BizSpark is a (nearly*) free program and if you don’t use it, even just part of it, you are missing a few brain cells. *$100 enrollment fee (due when you exit the program)

Wrapping Up

photo (2)

Congrats to the winning teams and props to everyone who came along and coded their hearts out for 54 hours to deliver a wide array of cool solutions on various platforms.  There’s nothing like passionate people and innovation going on to make people stay awake for 54 hours building cool shit.

I’m looking forward to future Startup Weekends and am really interested to see what other groups of entrepreneurs and startups can come up with as Startup Weekend continues to rock the world!

Thanks to the Clint and Marc from Startup Weekend team for coming to Seattle and hosting the biggest event ever!



Tags:

My Openness is bigger than your Openness – Windows Live ID and Open ID

Today the Live ID team wrote about their findings from the Open ID preview we had been running since PDC last November.  We explored what works and what doesn’t work with the cornerstone of the Open Web, Open ID, for services with a large user base such as Windows Live which has 500+ million users worldwide.

The findings highlighted a couple of things for me: 

  1. More work needs to be done on Open ID to make it ready for the masses.  We want seamless mass adoption not mass confusion.  In particular the Live ID team called out aliasing as being “unfeasible and/or just plain confusing to users!”
  2. The more frequently bigger players (Microsoft, Facebook, MySpace etc) get involved and contribute feedback to the Open Web communities like Open ID, the more rapidly they can move forward and shape standards that fit everyone rather than just early adopters.  In essence the bigger players provide more perspective, fresh eyes if you will.  We will and need to drive this behavior more at Microsoft.
  3. And finally, an observation that made me smile was how the Open Web drives a lot of interesting behavior with people getting envious and feeling the need to blow their own trumpets.  For instance, if you look at the Open ID mailing list notice how Google can’t help but point out their efforts in this space too.  It’s cute, but let’s not forget this isn’t a PR exercise this is about providing real feedback from real users whom we want to adopt this stuff. I would prefer Google to augment our feedback and provide perspective on such an announcement.

Today Microsoft and the Open ID took some great steps towards an Identity mechanism that works for the web.  It’s going to be great to see this feedback worked back into the spec.  After all it ain’t “my openness is bigger than your openness” it’s “our openness” and we’re not competing, we’re working together on this.



Tags:

Tweetdeck sync rocks but UX needs some work

I love the fact that Tweetdeck has a feature that allows you to sync your Twitter groups and searches between computers by typing in your Tweetdeck credentials*.  The only gripe I have is that where I have long search names they add an annoying scroll bar that makes it almost impossible to read the search term and click the check box.

image

Sync’ing settings and configurations of desktop apps between different machines will be a trending feature in software over the coming years and I don’t expect the likes of Tweetdeck to roll their own sync engines in the future.

* Why didn’t they just use my Twitter handle?



Tags:

Windows 7 selling “cheap as chips” in the UK

David Dickinson

Well I’ll be.

It looks like back home in Blighty my friends and family will be able to pick up copies of Windows 7 for the princely sum of 65 (GBP)* for the Home Premium Version.  Amazon are already flogging it on their website and Nate has all the details in his CNET UK article.

For those of you interested in an upgrade and who are going to be playing IT department for your friends and family on release day**, Sir Scott Hanselman has some details on upgrade paths and how to get Win7 on your box with the minimum of fuss.

For those of you wondering who that chap on the throne is above, please refer to this website.

* I lost the pound sterling key on my keyboard! :(
** See my future posts on me upgrading my girlfriend’s laptop from OSX to Win7 :)



Tags:

Roll up, roll up Zune HDs now on pre-order

Zune HD. The wait if over. Pre-order yours today.image

Says it all really.  Looking forward to getting mine! Get yours too.

Gizmodo has all the details on the Zune HD.

Tags: