Windows Azure Training Kit – December 2012

Good News! The world didn’t end, which is good for two reasons, first we’re all alive, but also my team has been working hard to provide you another great Windows Azure Training Kit release.

What’s new in this release?

Back in October, you may have heard of a massive on campus Microsoft event known as Build. Build was a great event filled with an absolutely everything you need to know about Windows 8, Windows Phone 8 and Windows Azure Development. If you haven’t already done so, check out the day 2 keynote which highlights all of the news around Windows Azure.

In this release we’ve packaged up the day two Keynote demos for you to be able to look at the code or deliver a similar session using the very same demos.

Event Buddy Demo

eventbuddy-session-list

In this demo you will start with a disconnected application that manages events and sessions to later connect it utilizing Windows Azure Mobile Services to provide structured storage for events and sessions. In order to use authentication within the application, you will add Twitter (or Facebook) to your application and services. Following this you will upload session decks to SkyDrive and finish by sending Live Tiles using push notifications every time an attendee rates a session.

BUILD Clips Demo

upload-video

In this demo, we will show how to build and deploy an ASP.NET web site that enables users to browse, play, and upload their own personal videos. We will then extend the web site to include Web APIs that power a Windows 8 experience. Finally, the web site project will be deployed to Windows Azure Web Sites and scaled using multiple paid shared instances.

Windows Azure Mobile Services – Scheduler

We have updated the Windows Azure Mobile Services Presentations, Demos and Hands-on Labs to include the new scheduler functionality. If you want some more information about the new scheduling functionality in Windows Azure Mobile Services, check out Scott Guthrie’s post.

Updated Repositories

You can download the offline training kit (Windows only) or grab the files from GitHub.

How To Create Custom MVC Extension Methods

 

My good friend John MacIntyre [@JohnMacIntyre] was curious about how to add additional mark-up to an MVC Helper Method. This can be achieved by using Extension methods.

There are a few namespaces or classes that you will want to keep in mind when creating new HtmlHelper Methods of your own.

For this example I will be showing how to create the following mark-up in an extension:

<a href="[action-link]"><span>[action-link text]</span></a>

To get this started I’ll make a static class called HtmlExtensions, this is where I will build my library of ASP.NET MVC Extensions. I’ll be creating an extension method called ActionLinkWithSpan which will Extend the HtmlHelper Class. Let’s take a look:

I used the TagBuilder Class to help create the html elements I wanted to output. The UrlHelper class (which in a MVC View is the Url Property) quite easily creates the link we need based on the input parameters provided.

To use this in our View to generate our link we simply import the namespace it was placed in (or add it to the pages/namespaces section in the web.config) then select it from the intellisense (or type out the Method name) using the Html Property.

<%: Html.ActionLinkWithSpan("Navigate Here", "Index", "Home", new { id="myLink", @class="link" })%>

Well John, I hope this is very helpful.

Happy Coding!

How to Change ASP.NET MVC ValidationMessageFor from <span> to <label>

When it comes to providing a more usable interface for your user, I find that labels are the key. Being able to style a label as an error message and position it where you need it for your user is great, the added functionality being, if the user clicks on the label it lands their cursor nicely in the corresponding field [provided you have filled in the ‘for’ attribute].

When it comes to ASP.NET MVC, Microsoft made the choice to go with a <span> tag instead of the <label>.  I’m not sure why they made this decision, and please feel free to comment below if I’m breaking an html rule here, but a label for error validation just seems to be a no brainer to me.

If you feel the same here is a snippet of Code I created to be change a ValidationMessageFor Extension Method into a Method that provides the label error messaging.

I know that Regular Expression can cause some performance issues, and I don’t call myself a RegEx Master, so if you find a more efficient way to do this please Contact Me, and I will be sure to post the code change.

Remember: “friends don’t let friends __doPostBack();”

Happy Coding!

Having Cassini Crash while using ASP.NET MVC

This will be a short entry, but I think that it might save some people some time when building out ASP.NET MVC websites.

If you find that Cassini is crashing when you are testing out your ASP.NET MVC Application here is one more thing to check. Look at your master page file, it is generally a good idea not to touch any of the code that gets generated by the Visual Studio Designer, but from time to time you may find yourself playing around with the code in order to minimize the amount of content is being pushed out to the client.

The Masterpage file still requires a <head> with the runat=”server” attribute. This is required to render the content in the Placeholders within it. With that said, if you are to remove the runat=”server” you will experience an error, in my case, the cassini web server would crash when ever I tried requesting a page with the invalid masterpage.

With any luck, this will help you out!

Happy Coding!