1
我有一个ASP.Net MVC网站,我想通过URL Action将文本框的值从视图传递给控制器。如何将TextBox值传递给MVC剃须刀中的URL.Action?
下面是我的代码,
<table class="table table-striped table-bordered table-hover" id="products" width="100%">
<thead>
<tr>
<th>ProductId</th>
<th>Name</th>
<th>ShortName</th>
<th>ProductNamePrefix</th>
<th>Minimum Count</th>
<th>Add Product</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ProductId)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.ShortName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ProductNamePrefix)
</td>
<td>
@Html.TextBox("MinCount", item.MinimumCount, new {@class = "form-control" + " " + item.ProductId})
</td>
<td>
@if (item.IfExists == true)
{
<div class='isa_success'><i class='fa fa-check'></i></div>
}
@if (item.IfExists == false)
{
<a href="@Url.Action("AddProduct", "Home", new { ProductId = item.ProductId, Name = item.Name, ShortName = item.ShortName, ProductNamePrefix= item.ProductNamePrefix, MinimumCount= item.MinimumCount})"><div class='isa_info'><i class='fa fa-plus-circle'></i></div></a>
}
</td>
</tr>
}
</tbody>
</table>
我想通过在URL操作方法的文本框的值到控制器。我正在创建一个基于id的文本框的自定义类,但我无法使用javascript或jQuery检索它。
哪个文本框的值?你的AddProduct有一个参数来接受它吗?这叫什么 ? – Shyju
它是MinimumCount文本框,是控制器接受这个参数。但它始终是空的。 – Arpita
你想要初始值或更新值(用户可以编辑文本框的值。rite)?你为什么不做表格帖子? – Shyju