Im new to ASP .NET MVC Web Aplications and i please need some help. I need to summ two values ("Cena" and "Kolicina") and save into textbox "Znesek". How should i do this? I tried this (How to multiply values of two textboxes in Asp.net MVC) but its not working for me :/
Here is my .cshtml file:
<div class="form-group">
@Html.LabelFor(model => model.kolicina, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.kolicina, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.kolicina, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.cena, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.cena, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.cena, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.znesek, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.znesek, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.znesek, "", new { @class = "text-danger" })
</div>
</div>
Please help me, what i need to change or where i need to do some action?
EDIT: Sure, i have @Html.BeginForm and everything what is needed for View code, this is just partial code. Everything is working, i can save all to SQL database and display it, i just down know how to multiple fields...
Here is my controler POST Code:
public ActionResult Create()
{
ViewBag.zapStDoumenta_tk = new SelectList(db.dokumentGlava, "zapStDokumenta", "zapStDokumenta");
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "zapStPostavke,artikel,kolicina,cena,znesek,davek,popustNaPostavko,zapStDoumenta_tk")] postavkaDokumenta postavkaDokumenta)
{
if (ModelState.IsValid)
{
db.postavkaDokumenta.Add(postavkaDokumenta);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.zapStDoumenta_tk = new SelectList(db.dokumentGlava, "zapStDokumenta", "krajIzdaje", postavkaDokumenta.zapStDoumenta_tk);
return View(postavkaDokumenta);
}

@Html.BeginForm). Show the complete View code, and the controller method that you're POSTing to.