Downloads from Building Rich Input Forms in ASP.NET MVC Webcast

Thanks to all who attended my webcast yesterday. Here is the recorded video, slides, and demo application.

SlidesKennedy-Rich-Forms-with-ASP.NET-MVC-Slides.zip
Demo ApplicationKennedy-MVC-Forms-Demo.zip

Video Recording:

Remember, you’ll need to run MongoDB to make the web app work. Read the readme in the zip file for details (it’s easy!).

Cheers,
@mkennedy

5 thoughts on “Downloads from Building Rich Input Forms in ASP.NET MVC Webcast

  1. Hi Michael,

    Happy Holidays from Las Vegas !
    Very instructive hands-on tutorial for MVC Forms.

    A small beef is the unresolved issue with model binding validation for the ( [Required] ) dropdownlist. Sorry it didn’t work out of the box and you mentioned about manual approach without the required attribute, shouldn’t this work ?

    Best, LA Guy

  2. Happy Holidays Michael,

    Very nice job with a hands-on walkthrough covering the basic concepts. :)

    As usual, there is a dearth of in-depth videos which cover topics such as below.

    Hope you can comment on how to do Required DropdownList validation using the [Required] attribute instead of a manual validation on the serverside ( as you mentioned ) ?

    Also, would be nice to cover the many to many example where multiple categories could be
    assigned to a book.

    Best, Paul

  3. Hi Michael,

    Just in case anyone is interested in getting the Mongo ObjectID ( Guid ) working with the dropdown, then the ViewModel should use a String for the CategoryId and then convert to Mongo
    ObjectID

    +++ VIEWMODEL
    public class BookViewModel
    {
    //public ObjectId CategoryId { get; set; }
    [Required]
    public string CategoryId { get; set; }
    [Required] public string Name { get; set; }
    [Required] public string ImageUrl { get; set; }
    [Required] public float Price { get; set; }
    }

    +++ VIEW

    @using(Html.BeginForm())
    {

    Category: @Html.DropDownListFor(m => m.CategoryId, categories)
    Title: @Html.TextBoxFor(m => m.Name)
    Image Url: @Html.TextBoxFor(m => m.ImageUrl)
    Price: @Html.TextBoxFor(m => m.Price)

    }

    +++ CONTROLLER ACTION

    [HttpPost]
    public ActionResult AddBook(BookViewModel viewModel)
    {
    if (!ModelState.IsValid)
    {
    ViewBag.CategoriesList = GetCategoriesList();
    return View(viewModel);
    }

    Book book = new Book();

    book.CategoryId = new ObjectId(viewModel.CategoryId); // viewModel.CategoryId;
    book.Name = viewModel.Name;
    book.Price = viewModel.Price;
    book.ImageUrl = viewModel.ImageUrl;

    repository.Save(book);

    return Redirect(“/books/show/” + book._id);
    }

    Merry Xmas, Paul

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s