I don't know why its not working there is nothing complicated. I am just passing model to view and then getting the model back from view for updating.
Controller :
[HttpGet]
[ActionName("Test")]
public ActionResult Test_get()
{
Testing t = new Testing();
t.a = 100;
t.name = "ali";
t.age = "29";
return View(t);
}
Model:
public class Testing
{
public int a = 0;
public string name;
public string age;
}
View:
@using(Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.Label("name")
@Html.EditorFor(m => m.name)
@Html.Label("age")
@Html.EditorFor(m => m.age)
<button type="submit" value="Change Text" />
}
and this method get model back
[HttpPost]
[ActionName("Test")]
[ValidateAntiForgeryToken]
public ActionResult Test_post(Testing t)
{
Testing get_t = new Models.Testing();
get_t = t;
return View();
}
but it returns null model please help me this is just demo I am stuck in my project.