来自MVC文本框的空值 [英] Null values from MVC textboxes
本文介绍了来自MVC文本框的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试在mvc视图中使用多个文本框时,只有第一个传递值,其他所有传递空值。
我尝试过:
这一个通过值
When I'm trying use multiple textboxes in mvc view only first one pass the value other all passes null values.
What I have tried:
This One Passes Value
<label class="col-md-3 control-label">A Title</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })
这些是Null。
These are Null.
<label class="col-md-3 control-label">B Title</label>
@Html.TextBoxFor(model => model.A , new {@class = "form-control input-inline input-medium" })
<label class="col-md-3 control-label">cTitle</label>
@Html.TextBoxFor(model => model.B , new {@class = "form-control input-inline input-medium" })
推荐答案
您需要使用其他模型类型值。
您现在使用3次model.NpdTitle。
所以当你改变3中的1时,它会将model.NpdTitle设置为一个值。
< label class =col-md-3 control-label> A Title< /标签>
@ Html.TextBoxFor(model => model.NpdTitle ,new {@class =form-control input-inline input-medium})
< label class = col-md-3 control-label> B Title< / label>
@ Html.TextBoxFor(model => model.NpdTitle ,new {@class =表格控制输入 - 在线输入媒体})
< label class =col-md-3 control-label> cTitle< /标签>
@ Html.TextBoxFor(model => model.NpdTitle ,new {@class =form-control input-inline input-medium})
制作npctitel,npbTitle和nptTitle或类似的东西
You need to use a other model type value.
You now using 3 times model.NpdTitle.
So it will set model.NpdTitle to a value whenever you change 1 of the 3.
<label class="col-md-3 control-label">A Title</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })
<label class="col-md-3 control-label">B Title</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })
<label class="col-md-3 control-label">cTitle</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })
make npctitel, npbTitle and nptTitle or something simulair
这篇关于来自MVC文本框的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文