views:

36

answers:

3

hello friends,

<div>
        <label>
            Date:
         <span><input type="text" id="date" /></span>
        <%--<%=Html.EditorFor(model=>model.Date) %>--%> // Should I use this as Input type?
        </label>
        <label>
            Number#:
            <%=Html.TextBox("Number", ViewData["inq"] ?? "")%>
        </label>
        <label>Comment</label>
        <span>
           <%=Html.TextArea("value")%>
           <%=Html.ValidationMessage("value")%>
          </span>
    </div>

I am trying to get these three fields 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

A: 

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();
        }
Malcolm Frexner
A: 

you can call void controller

kusanagi
A: 

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.

RPM1984