ASP.NET MVC Preview 5 Released

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); %>

      .csharpcode, .csharpcode pre
      {
      font-size: small;
      color: black;
      font-family: consolas, “Courier New”, courier, monospace;
      background-color: #ffffff;
      /*white-space: pre;*/
      }
      .csharpcode pre { margin: 0em; }
      .csharpcode .rem { color: #008000; }
      .csharpcode .kwrd { color: #0000ff; }
      .csharpcode .str { color: #006080; }
      .csharpcode .op { color: #0000c0; }
      .csharpcode .preproc { color: #cc6633; }
      .csharpcode .asp { background-color: #ffff00; }
      .csharpcode .html { color: #800000; }
      .csharpcode .attr { color: #ff0000; }
      .csharpcode .alt
      {
      background-color: #f4f4f4;
      width: 100%;
      margin: 0em;
      }
      .csharpcode .lnum { color: #606060; }

Advertisements

jQuery – Draggable Selectables

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 .csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

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

ASP.NET MVC In Action (MEAP)

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

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

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