How to get these values front end using asp.net mvc
I am trying to get these three fields 开发者_Go百科on the screen while user enters I am retreving the user enter data on front end.. when I am debugging I am not seeing these fields..
On the view I am using beginForm
<% using (Html.BeginForm("Update", "Home", FormMethod.Post, new { @id = "id" }))
{ %>
my method..
public JsonResult Update(StudentInfo info)
{
///Update
return Json(Status.ToString());
}
when I see in info I am not getting these three fields..
can any one help me out thanks
You are returning a JsonResult but doing as Http post (Html.BeginForm). If you want to use a full form post then return a ActionResult.
public ActionResult Index()
{
// Add action logic here
return View();
}
you can call void controller
It makes no sense that you're returning a JsonResult from a HTML Post.
Do this instead.
[HttpPost]
public ActionResult Update(StudentInfo info)
{
///Update
if (updateWorked)
return View("Success", status);
}
You use JsonResult when you want to call a controller that returns JSON data, in order to display this data somewhere on your page.
A useful scenario for JsonResult in your scenario would be returning a json list of Students, executed from a click event maybe (call in JavaScript/jQuery).
Calling an action method on a HTTP Post which returns a JsonResult of a single string (not real JSON) makes no sense.
精彩评论