How to Sum Two @Html.TextBox values and Display It In another @Html.TextBox In MVC

Posted by Kasani007 under ASP.NET MVC on 8/8/2014 | Points: 10 | Views : 2416 | Status : [Member] | Replies : 1
How to Sum Two @Html.TextBox values and Display It In another @Html.TextBox In MVC




Responses

Posted by: kgovindarao523-21772 on: 8/11/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
To implement this, you can use javascript or jquery function on button click.
or else if you want to exactly MVC way,
Bind text boxes using model class properties to each input text box and display result in another text box by sum.

sample code in .cshtml:
@model YOURMODEL
<input type="text" value="@PropA" />
<input type="text" value="@PropB" />
@{
int result=PropA+PropB
}
<input type="text" value="@result" />



Thank you,
Govind

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response