Tech.Ed Australia Tech Talks & Panel

While at Tech.Ed Australia last week I took part in a couple of Tech Talks and a panel discussion about building for “Reach” or “Rich” web experiences. Details below.

Tech Talk: ASP.NET MVC vs. ASP.NET Web Forms – will webforms be replaced by MVC?

ASP.NET MVC is currently the technology flavour of the season. ASP.NET webforms has been a dominant development platform for a long time but MVC is receiving a lot of focus and is the choice of architetecural purists. Does this signal the demise of ASP.NET webforms? Should we be choosing MVC for all future projects?

See the video here

Tech Talk: Building Fast, Public Websites

Building public websites can be hard at the best of times. Making them fast can be even harder. What makes a website faster? What makes it appear faster to users? How can you leverage features of ASP.NET to get the best experience for your users? Tune in to hear two ASP.NET MVPs share some of the problems they had to solve while rebuilding Australia’s largest e-commerce site.

See the video here

Panel: Rich vs. Reach – should we develop apps for the lowest common denominator?

See the video here

Advertisements

Readify Developer Network Dev Day, Melbourne Fri 9th October

I’m hosting half of the upcoming Readify Developer Network Dev Day in Melbourne on Friday the 9th of October. I’ll be talking about “Building for the Web with .NET” and Mitch Denny will be talking about “Software Quality and Application Lifecycle Management”. The cost is minimal and you can choose to attend the whole day or just the topic that interests you. Hope to see you there.

Readify Developer Network Dev Day

MELBOURNE | Friday 9th October 2009

Hear from Microsoft Tech.Ed 2009 Presenters and MVPs, Mitch Denny and Damian Edwards

RDN Dev Days are comprehensive presentations on relevant topics that can help your business thrive. All RDN Dev Days are presented by expert Readify

developer consultants and attendees are provided a variety of topic streams to choose from.

Join us for our upcoming RDN Dev Day and hear the latest on ‘Software Quality and Application Lifecycle Management’ and ‘Building for the Web with .NET’.

By attending this seminar you will gain greater knowledge and insight into the tools needed to assist you and your team in achieving your business objectives.

Each presentation is of a world-class standard as most Readify consultants are well recognised and highly regarded within the industry and present regularly at

events such as Tech.Ed, ReMIX, CodeCamp Oz, User Groups, plus many more. Readify also has eleven Microsoft Most Valuable Professionals (MVPs) on board.

Event Details:

Date: Friday 9th October 2009

Location:               MELBOURNE | Cliftons Corporate Training Centre – 440 Collins Street (click here for location information & map)

Times:                    Stream A & B | 9am – 5pm

Stream A only | 9am – 12.30pm

Stream B only | 1.30pm – 5pm

A light lunch will be served from 12:30pm – 1:30pm for all attendees

Investment:         Stream A & B (full day)  |  $150 + GST …register now

                                Stream A only (half day)  |  $75 + GST  …register now

Stream B only (half day)  |  $75 + GST  …register now

Bookings:              Register online* or phone 1300 666 274

Topics:

STREAM A :

Software Quality and Application Lifecycle Management

Presented by Mitch Denny (MVP) | Chief Technology Officer, Readify   

Gathering Quality Requirements for Agile Development Teams
Agile software development teams are supposed to be able to operate with incomplete requirements. The problem is that incomplete requirements are often

confused with poor quality requirements and too many agile software development teams start writing code without a good idea of what it is that they are actually

trying to achieve.

In this session Mitch will introduce you to SketchFlow, a component of Expression Blend 3, and look at how you can use it within your projects to rapidly produce

prototypes and gather feedback from customers and how to integrate this with Team System.

Introduction to Visual Studio Team System 2010
Visual Studio 2010 is just around the corner and quality is the number one focus of this release. In this session, Mitch will look into the features planned in the

upcoming Visual Studio 2010 release and explain how they can be used in software teams. Mitch will cover:

  • What is in it for developers?
  • What is in it for testers?
  • What is in it for architects?

STREAM B :

Building for the Web with .NET

Presented by Damian Edwards (MVP) | Senior Consultant, Readify

During this session, Damian will cover the following areas:

  • Building Fast, Standards Compliant ASP.NET Websites
  • ASP.NET MVC: Building for the web
  • Introduction to the ASP.NET Web Forms Model-View-Presenter framework

* BOOK NOW AS SEATS ARE LIMITED! *

*Registrations now open and will be closing on Wednesday 7 October.


Access Key Highlighter plugin for jQuery now available

I’ve just published my first jQuery plugin release. It’s a port of my Access Key Highlighter control for ASP.NET AJAX that I released last year. I’ve rewritten the control for jQuery and plan to implement new features in both versions of the control from now on. You can see a live demo of it running at http://files.damianedwards.com/KeyTips/

Access Key Highlighter popups on form field labelsAccess Key Highlighter popups on buttons and hyperlinks

 

If you have any feedback or feature suggestions go ahead and leave a comment here.


Setting up jQuery for ASP.NET Web Forms projects

During my recent presentation to the Victoria.NET DevSIG on jQuery, I talked about how to get started using jQuery with ASP.NET Web Forms projects. Part of this was around how I like to set up my projects with jQuery to take advantage of the script management features that ASP.NET & Visual Studio 2008 provide out of the box.

ASP.NET provides support for switching in different versions of your JavaScript files at runtime depending on the compilation setting in your web.config file (debug=true or false) via the ScriptManager control. This allows you to have your development script used during development & debug time, and an optimised script (minimised, obfuscated, etc.) used at release time. You can enable this feature of the ScriptManager with your own files (it does it automatically for the MS AJAX framework files) in a few ways, the easiest of which is to set the ScriptMode property of your ScriptReferences to Inherit.

<asp:ScriptManager runat="server">
     <Scripts>
         <asp:ScriptReference Path="~/script/myScript.js" ScriptMode="Inherit" />
     </Scripts>
</asp:ScriptManager>

Further to this, Visual Studio 2008, by way of a hot fix, adds support for a third type of JavaScript file, used only for providing JavaScript IntelliSense within the Visual Studio IDE. These special versions of your script files (known as “VSDoc” files) are carefully constructed to ensure optimal IntelliSense relevance, information & performance and generally are not able to be used at runtime at all.

So we have three file types in all as follows:

  • Release mode file: myscript.js
  • Debug mode file: myscript.debug.js
  • VSDoc file: myscript-vsdoc.js

When you download jQuery, you have the option of the standard file (jquery-1.3.2.js at time of writing) as well as the “production” file, which is minimised (jquery-1.3.2.min.js). Microsoft have also contributed a VSDoc file which you can download from the official jQuery source repository on Google Code.

So there are three types of jQuery files that match up with what ASP.NET & Visual Studio support, just two of them have the wrong extension. All we need to do is rename the files to match the features in the platform & tools:

  • jquery-1.3.2.js => jquery-1.3.2.debug.js
  • jquery-1.3.2.min.js => jquery-1.3.2.js

I have this files in a location on my hard drive where I can always get to them for new projects:

image

To use them in a project, just create a folder to hold them and right-click in solution explorer and choose Add –> Existing Item…

image

Now simply add a script reference for the jQuery files in the same way as you would for your own script. ASP.NET will use the large debug version when the app is in debug mode & the minimised version when it isn’t, plus you’ll get great IntelliSense support from Visual Studio 2008:

<asp:ScriptManager runat="server">
     <Scripts>
         <asp:ScriptReference Path="~/script/jquery-1.3.2.js" ScriptMode="Inherit" />
         <asp:ScriptReference Path="~/script/myScript.js" ScriptMode="Inherit" />
     </Scripts>
</asp:ScriptManager>

It would be nice if the next version of ASP.NET included support for jQuery’s default file extensions in the ScriptManager control, but until then this works very well.


Updating the ASP.NET validator controls to change invalid control’s CSS class on non-JavaScript clients

In my previous post I showed how you could add support for the ASP.NET validation controls to automatically change the CSS class of invalid controls on the client side using some jQuery. But what about when the client doesn’t have JavaScript enabled?

The simple anwser is to sub-class the built-in ASP.NET validation controls and add this behaviour ourselves, then use tag mapping in the web.config file to automatically use our modified validator controls instead of ASP.NET’s built-in versions.

The following is an example of how you could sub-class the RequiredFieldValidator control to support changing the CSS class of the associated control when it fails validation:

using System;
using System.Linq;
using System.Web.UI.WebControls;

namespace WebApplication16.Controls
{
    public class ClassChangingRequiredFieldValidator : RequiredFieldValidator
    {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            var ctl = NamingContainer.FindControl(ControlToValidate) as WebControl;
            if (ctl != null)
            {
                if (IsValid)
                {
                    var className = String.Join(" ", ctl.CssClass.Split(' ')
                        .Where(c => !c.Equals("error")).ToArray());
                    ctl.CssClass = className;
                }
                else
                {
                    if (ctl.CssClass.Split(' ').FirstOrDefault(c => c.Equals("error")) == null)
                    {
                        ctl.CssClass = String.IsNullOrEmpty(ctl.CssClass) ? "error" : ctl.CssClass + " error";
                    }
                }
            }
        }
    }
}

Next you need to add some configuration to your web.config file to force ASP.NET to use this control instead of the build-in version:

<pages styleSheetTheme="SiteTheme">
 <controls>..</controls>
 <tagMapping>
 <add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="WebApplication16.Controls.ClassChangingRequiredFieldValidator" />
 </tagMapping>
</pages>

Make sure you change the namespaces to match your application’s.

Just repeat this process for the other validation controls and combine it with the technique in my previous post to get your invalid controls’ CSS class automatically changed, either client-side if the user has JavaScript enabled, or server-side if not.


Set the CSS class of ASP.NET invalid controls using jQuery

The ASP.NET validation controls are a very quick and effective way to add client-side & server-side validation to your web forms but they lack one very important feature out of the box: the ability to change the CSS class of the controls that are invalid. Changing the class of the invalid controls will allow you to style them in such a way that they help bring attention to the fact that the user needs to do something more to complete the form successfully.

It is quite simple to add this functionality (for clients with JavaScript enabled at least) using a little bit of JavaScript and everybody’s favourite JavaScript library, jQuery!

First of all, set the CssClass property of all your validator controls to “validation-error”. The easiest way to achieve this is by using a skin file. See this post for more details on how to do this.

Then add the following to your site’s JavaScript file (assuming you’re already using jQuery):

 
/// <reference path="jquery-1.3.1.js" />

$(document).ready(function(e) {
    $("span.validation-error")
        .bind("DOMAttrModified propertychange", function(e) {
            // Exit early if IE because it throws this event lots more
            if (e.originalEvent.propertyName && e.originalEvent.propertyName != "isvalid") return;

            var controlToValidate = $("#" + this.controltovalidate);
            var validators = controlToValidate.attr("Validators");
            if (validators == null) return;

            var isValid = true;
            $(validators).each(function() {
                if (this.isvalid !== true) {
                    isValid = false;
                }
            });

            if (isValid) {
                controlToValidate.removeClass("error");
            } else {
                controlToValidate.addClass("error");
            }
        });
});

And there you have it. Now when any validator on your form has the isValid property tripped to false on the client side, the CSS class of the offending control will be changed to “error”.


Visual Studio 2008 XHTML 1.1. Templates – v1.1.1 Released

I’ve just posted a new release of the Visual Studio 2008 XHTML 1.1 Templates on CodePlex that fixes a couple of minor issues. If you use the templates and have any feedback I’d love to hear it.