1
//its in ajax success
document.getElementById('koeff').innerHTML = elements.total;//type string

Posting form:

@using (Html.BeginForm("Index", "Power", FormMethod.Post))
{
        <p>Sum:  <span id="koeff" name="mult"></span></p>
      //other code with submit button
}

Controller:

public ActionResult Index(string mult)//  mult null why?
{
}

In controller mult always null, why?

1
  • 2
    Your element is a <span>, not a form control (e.g. <input>). Only form controls submit values. Commented Apr 21, 2016 at 22:01

1 Answer 1

1

This will do it:

@using (Html.BeginForm("Index", "Power", FormMethod.Post))
{
        <input type="hidden" id="koeff" name="mult" />
      //other code with submit button
       <p>Sum: <span>@ViewBag.Mult</span></p>
}

You can display sum as a label or span if you need user to see it on the page, but to post, it must be an input. In my case it's hidden input, but you can have test or any other input.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.