I have a model like this:
public Products()
{
string name {get; set;}
string category { get; set;}
}
I was trying to create an object within an action method or to pass as a parameter to that method & use that object to create the view by passing that object to view method. I was expecting the framework to create an appropriate view to show the products. Is it the right way to do this? I have a feeling I’m missing something in between heavily, but can’t figure it out.
Thnaks.
Straight from MSDN: http://msdn.microsoft.com/en-us/library/dd410405.aspx
The main idea is model binding is done automatically in asp.net mvc. You only need to pass the model to the view for the get method and retrieve the model as a parameter in the post method like so:
and in the view you must have at the top
@model Productsand input the fields like so:@Html.EditorFor(m=>m.name)and@Html.EditorFor(m=>m.category)Be honest. You did not searched the web.