In this chapter, we will cover:
One of the big advantages that ASP.NET MVC has over web forms is the ease with which you can work with forms. In this chapter, I'll take you from the basics of setting up a form using HTML helpers to more advanced concepts such as autocomplete.
I'd suggest looking at the first recipe before jumping further into the chapter, as I'll be using the project created there as a baseline for all of the other recipes.
The majority of the recipes in this chapter will need a model to work with. To make life easier, I have created a simple Article
class, which will help demonstrate the different ways in which ASP.NET MVC deals with data types.
Models/Article.cs:
public class Article {
public Guid ID { get; set; }
public string Title { get; set; }
public string Subject { get; set; }
public string Description { get; set; }
public DateTime CreateDate { get; set; }
public bool IsPublished { get; set; }
public int TimesViewed { get; set; }
public string FormattedCreateDate
ASP.NET MVCASP.NET MVCdata types, dealing with{
get
{
if(CreateDate != DateTime.MinValue)
return string.Format("{0:d/M/yyyy HH:mm:ss}", CreateDate);
return "";
}
}
}