Archive for August, 2008

ASP.NET MVC Preview 5 Released

August 30th, 2008

http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16775

Release Notes

This ASP.NET MVC CodePlex Preview 5 is an interim release that contains some new features and some feature improvements for which the ASP.NET MVC team would like to receive feedback from the community. As always, feel free to provide feedback on the ASP.NET MVC forums.
Note: Before you run the ASP.NET MVC CodePlex Preview 5 installer, be sure to uninstall any earlier previews of ASP.NET MVC that you might have installed. In addition, close all instances of Visual Studio 2008.
The follwing issues are addressed in this release (see the Release Notes for more detail on any changes)

  • Html Helpers need to look into ModelState to get attempted value
  • Add a convenience overload for Html.ActionLink
  • Need friendly exception for UpdateModel type conversion errors.
  • UpdateModel needs to report a message when a property setter throws an exception

note: we are working on adding the source code for this release and expect it to be available shortly…

 

Here is interesting post on form validation with preview 5…

http://blog.maartenballiauw.be/post/2008/08/29/Form-validation-with-ASPNET-MVC-preview-5.aspx

 

(this preview definitely breaks MVCContrib… So, I’ll be waiting for the MVCContrib to get updated before updating any of my projects)

 UPDATE: I was able to get ahold of the MVCContrib Preview 5 branch to get a build that works with preview 5.

Items that are ‘gotcha’s:  make sure you add the Microsoft.Web.Mvc assembly as well as add the namespace to the config…

  • “UpdateFrom” from BindingExpression has been replaced by UpdateModel
  • Html.TextArea, add an extra null at the end of the parameter list (for HTMLAttribs)
  • Html.Checkbox, the parameter list has changed, no ‘text’ parameter, which is good – I did notice the ‘BuildCheckBox’ function is gone – so on my ‘CheckBoxList’ helper, I build manually with the Html.CheckBox
  • this.ReadFromRequest… gone… Obviously they want you to use the whole UpdateModel, etc… so, what I did was create a ‘ReadFromRequest’ in my base class for my own use for now, it returns a string and takes a string – returning Request[key]
  • There is now a ‘LinkBuilder’ class in the Microsoft.Web.Mvc that replaces the BuildUrlFromExpression
  • RenderUserControl, etc… has been replaced with RenderPartial.  It basically is the same exact usage, however some gotchas:
    • This one does NOT return a string, it writes it directly – so no ‘=’, and add the semi-colon at the end.  ie.
    • <% Html.RenderPartial("~/Views/Address/AddressControl.ascx", ViewData.Model.Company.Address); %>

jQuery – Draggable Selectables

August 29th, 2008

The jQuery UI library has support for ‘selectables’ and ‘draggables’.  But currently it doesn’t support ‘out of the box’ the ability to easily select a group of elements and then drag them as a group.

After some jQuery mailing list searches, the following link was shared:

http://pastebin.me/48b805049c7be

This is a really nice feature, and quite easy to implement!

jQuery Get’s a Makeover

August 28th, 2008

wow, I popped over to check some documentation and saw the new jQuery web design: http://jquery.com/

Slick ;)

ASP.NET MVC In Action (MEAP)

August 26th, 2008

Jeffrey Palermo is leading the charge on the ‘ASP.NET MVC In Action’ book that is part of the Manning Early Access Program:

http://www.manning.com/palermo/

Just in a quick overview of the Ajax section, I noticed some samples that were using jQuery  :)

I was thinking it would be all MS oriented, so this is good to see.

I have some high hopes for this because I think Jeffrey will deliver a good book.

jqmAjaxDialog (jqModal) ASP.NET MVC HtmlHelper Control

August 25th, 2008

I had a need today to create a new Html helper

See jqModal here: http://dev.iceburg.net/jquery/jqModal/

This helper duplicates this jqModal javascript:

$().ready(function() {
  $('#ex2').jqm({ajax: 'examples/2.html', trigger: 'a.ex2trigger'});
});
 
<a href="#" class="ex2trigger">
...
<div class="jqmWindow" id="ex2">
</div>
 
(see samples on the link above)
 

Now, I want to take this to ASP.NET MVC:

public static class jqmDialogExtensions
    {
        public static string jqmAjaxDialog<TController>(this HtmlHelper helper,

                  string dialogWindowName, string dialogTriggerName, 
                  Expression<Action<TController>> theAction)
            where TController : Controller
        {
            var sb = new StringBuilder();
            sb.AppendFormat("<div id=\"{0}\" class=\"jqmWindow\"></div>", dialogWindowName);
            sb.Append("<script type='text/javascript'>");
            sb.Append("$(function() {");
            sb.AppendFormat("$('#{0}').jqm(", dialogWindowName);
            sb.Append("{ajax: ");
            sb.AppendFormat("'{0}', ", helper.BuildUrlFromExpression(theAction));
            sb.AppendFormat("trigger:'{0}'", dialogTriggerName);
            sb.Append("});});</script>");
            return sb.ToString();
        }
    }
 
In the Html:
 
 <%= Html.jqmAjaxDialog<CompanyController>("SampleDialog", 
                    a.SampleDialogTrigger,
                    c => c.EditContactAddress(contact.Contactid.ToString()))%>
 
<a href="#" class="SampleDialogTrigger">Edit</a>
 

This is just a ‘quickie’ – as I didn’t want to be using ‘Response.writes’ or creating this in the controller code – maybe I can reuse it – that is the nice thing about these HtmlHelpers, they can be quick and easy to create and it modularizes some of that UI code.

Note again the use of the ‘BuildUrlFromExpression’ call – that is a favorite of mine  :)

Basically it looks at the controller, ie. CompanyController, then the lambda expression is used ‘c => c.EditContactAddress(contact.Contactid.ToString())’    – this will all be picked up by intellisense, makes it easy to pass parameters, and creates the correct url path to the action.

(Note: You’ll need to reference the jqModal and jQuery files)

Json.NET 3.0

August 25th, 2008

Has been released!  I’m a big fan of this library, it’s one of those ‘it just works’ projects  :)

Of greatly added benefit is that he has now added support for Silverlight.

Awhile back when I was playing with Silverlight, I was working with Json serialization, and the support within Silverlight didn’t work, but this library would.

Thanks again to James Newton-King for this release!

Key features:

  • Silverlight Support
  • LINQ to JSON even easier to use
  • Serializer Improvements

NHibernate 2.0.0 GA (note on NHibernate.Linq)

August 23rd, 2008

Good news from the NHibernate Team:

NHibernate 2.0.0.GA has been released today:

https://sourceforge.net/project/showfiles.php?group_id=73818&package_id=73969

Regarding the status of NHibernate.Linq:

From Tuna on the NH mailing list:

If you use releases, then it is better you don’t go for linq because there is no release for it and never will be until after 2.1

I suggest you to go and compile it yourself and make it compile if it doesn’t. The patch would be appreciated.

BTW, the contrib version will be have less interest because we want to concentrate on the new implementation and nowadays we can’t find enough time to deal with it.

 

Note as well – this release does not include a dialect for SQL 2008.

 

Update: I’ve decide to refactor out my ‘NHibernate.Linq’ code and replace it with ICriteria queries.  I had to refactor this before with moving away from the NHibernate Query Generator setup I had to NHibernate.Linq.  I decided having the 2.0.0 GA release was worth having now for stability, etc… and to bypass the NHibernate.Linq.  I kept all my queries, as perhaps in the future I would put them back in. 

Working directly with ICriteria has it’s advantages (as well as some disadvantages), but it feels a bit closer to the bone, which tends to mean I have more control over the queries, however I do like being able to the ‘II’ and ‘&&’ operators  :)

jQuery BlockUI

August 21st, 2008

One of my favorite jQuery plugins is the ‘BlockUI’.   I’ve been using this with my ASP.NET MVC applications.

I mostly use BlockUI as a way to prevent double submitting an entry on a form.   Since I’m using jQuery form validation as well, a typical ‘validate’ before submit looks like this:

"Before BlockUI":
$(function(){
    $("#AdjustmentAmount").maskMoney();
    $("#addCompanyDirectDepositFrm").validate().form();
})
 
"After BlockUI":
$(function(){
    $("#AdjustmentAmount").maskMoney();
    $("#addCompanyDirectDepositFrm").validate({
        submitHandler: function(form) {
            $.blockUI({ message: "Adding Direct Deposit...Please Wait<br/>" });
               form.submit();
              }
    }).form();
})
 

As you can see, it’s quite easy to implement.  I also use this on some redirects as well as Ajax calls.

Learn more about BlockUI here

(information on the validation library as well can be found here)

 

Document Map Margin

August 21st, 2008

So I saw this in my VS studio ‘news’:

http://blogs.msdn.com/charlie/archive/2008/08/15/future-focus-document-map-margin.aspx

Now, I had to laugh, as I hadn’t read the actually post yet, but the synopsis is:

Developers frequently work with huge source files that are difficult to navigate. The proposed DMM feature is designed to make it easier for you to find and track important features in your code and to visualize the overall structure of your file.

So… my first thought was: why don’t they refactor it so you don’t have ‘huge source files’  :)  

The real problem in my opinion is that rather than add a ‘document map’, how about we add better refactoring tools to help developers learn to get rid of these ‘code smells’ ?

ie. Resharper is good – but cost an arm and a leg as far as I’m concerned – meanwhile, the VS refactoring tools are kind of crappy – sure, it’s better than nothing, but they don’t even come close to what Resharper or Eclipse has.

Address the real issue  :)

Agile – Craftsmanship

August 20th, 2008

Bob ‘Uncle Bob’ Martin – adding a ‘fifth element for the Agile Manifesto’ – ‘Craftmanship’

Some snippets:

As you know the Agile Manifesto is composed of four balanced value statements. Here they are:

  • Individuals and interactions over processes and tools
  • Working software over comprehensive documentation
  • Customer collaboration over contract negotiation
  • Responding to change over following a plan

In my talk I proposed the following addition

  • Craftsmanship over Crap.

 

Most software development teams execute, but they don’t take care. We value execution, but we value craftsmanship more.

 

More can be found in this InfoQ post – including some reactions, etc… blah blah…  :)

Personally I like Sean Hanly’s article :

In today’s economy we have more to do with fewer resources. Giving software developers the right kind of skills means we can do this. I would take one developer who has the potential to be exceptional over two average developers any day.

What we need to do to fix our software processes is find Zen: assess our software development values, focus on quality and develop a craftsmanship approach to our work.

By the way, I’m going to order Uncle Bob’s newest book, I could use all I can get from ‘Clean Code’  :)   Hope it’s a good read!