using System.Web.Mvc;
namespace ViewSamples.Controllers
{
public class ViewDataController : Controller
{
public ActionResult Index()
{
ViewData.Add("one", "onevalue");
ViewData.Add("two", "twovalue");
ViewData.Add("three","threevalue");
return View(3);
}
}
}
WTF the 3 stands for ? IS it somehow magically related to "three" or the collection size ?
Try matching signatures in msdn:
View(Object) Creates a ViewResult object using the model that renders a view to the response.
Then continue reading "the book":
Notice the values that are added in the controller in listing 4.6. We have three key/value
pairs and an object set to the Model property (by virtue of passing in “3” to the View
method).
Virtue ? "3" ?
Passing some reasonable OBJECT as Model insted of magical autoboxing small int with coincidental value 3, would be bit easier to understand....
No comments:
Post a Comment