如何在mvc视图中添加文本框中给出的两个数字(.cshtml) [英] how to add two number given in text-box in mvc views(.cshtml)

查看:256
本文介绍了如何在mvc视图中添加文本框中给出的两个数字(.cshtml)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

这里我想用onkey函数添加两个文本框值。



hi to all,
Here i want to add two textbox value using onkey function.

@Html.TextBoxFor(model => model.value1, new { @class = "form-control control-text " })







@Html.TextBoxFor(model => model.value2, new { @class = "form-control control-text " })

<上面是我的两个文本框如何编写上面两个文本框的脚本并添加功能。



above is my two text box how to write script for above two text box and adding functionality.

推荐答案

Hii,



你可以在两个文本框中添加id属性,然后你可以用javascript或jQuery获取它们的值。



喜欢,

Hii,

you can add id attribute to both text boxes, then you can get their values in javascript or jQuery.

like,
@Html.TextBoxFor(model => model.value1, new { @class = "form-control control-text", @id= "txtBox1" })






and

@Html.TextBoxFor(model => model.value2, new { @class = "form-control control-text", @id= "txtBox2" })





现在在jQuery中,



Now in jQuery,

alert(


' #txtBox1')。val()+
('#txtBox1').val() +


' #txtBox2')。val());
('#txtBox2').val());


这篇关于如何在mvc视图中添加文本框中给出的两个数字(.cshtml)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆