in

DĂ© specialist in .NET trainingen en consultancy

Jo-wen Mei

december 2008 - Posts

  • test your jQuery

    Ok, I'm not very fond of javascript, so anything that facilitates working with it has my interest.

    jQuery does that job and is therefore getting more and more popular these days, proven by its intellisense support in VS2008.

    anyway, you can learn everything about it on their website, I just wanted to point out there is an interactive jQuery tester!

    You can test your selector with your own html... nice :)

    Posted dec 18 2008, 01:37 by Jo-wen with no comments
    Filed under:
  • using the ASP.NET compilation tool

    I'm automating the build/deployment process of my web app. This includes the "publish"-step. (right-mouse on the web project -> publish).

    The dialog presented is just a visual wrapper around the aspnet_compiler.exe.

    quote from msdn:

    "The ASP.NET Compilation tool enables you to compile an ASP.NET Web application, either in place or for deployment to a target location such as a production server. In-place compilation helps application performance because end users do not encounter a delay on the first request to the application while the application is compiled."

     

    I ran the command, and to my surpise, I received an error:

    "Could not load Type xxx"

     

    This was unexpected, because the option in Visual Studio worked fine.

    The caveat here is that there was a physical file present in the directory I specified, which was NOT part of the project.

    The command I used had the -p and -v params (which is pretty common), and compiles ALL physical files.

    So do a cleanup first!

     

    Note1: there are no 3.x updates of the aspnet_compiler, you can just use the 2.0 version.

    Note2: West Wind has created a visual tool to aid in generating the appropriate command.

  • Handling multiple selections in a MVC form

    Ok, I found something really cool today!

    I have multiple checkboxes that the user can select, and I was struggling to retrieve the selected values in my controller.

    Luckily, mvc offers some great assistence; check out this code:

     
    <% using (Html.BeginForm("ShowData", "Home")) {  %>
      <% foreach (var o in ViewData.Model) { %>
        <input type="checkbox" name="selectedObjects" value="<%=o.Id%>">
        <%= o.Name %>
      <%}%>
      <input type="submit" value="Submit" />
    <%}%>

     

    and all the selected items are available in a typed array!

     

    public ActionResult ShowData(Guid[] selectedObjects) {
        foreach (Guid guid in selectedObjects)
    {
           

        }
    }

     

    so, the trick is to use the same name for the controls, and the posted values are automagically put in an array.

    Nice :)

    Posted dec 07 2008, 04:13 by Jo-wen with no comments
    Filed under: