MVC-获取由jQuery脚本设置的文本框值
我正在使用jQuery设置MVC-获取由jQuery脚本设置的文本框值,jquery,asp.net-mvc,asp.net-mvc-4,Jquery,Asp.net Mvc,Asp.net Mvc 4,我正在使用jQuery设置文本框的值。我有一个文本框,如下所示:- @Html.TextBoxFor(model => model.Location, new { @disabled = "disabled" }) 在jQuery中,我为这个文本框设置了值:- $('#Location').val('xyz'); 在HTTPPOST上,我有以下代码:- [HttpPost] public ActionResult Location(FormCollection form, Locati
文本框的值。我有一个文本框
,如下所示:-
@Html.TextBoxFor(model => model.Location, new { @disabled = "disabled" })
在jQuery
中,我为这个文本框设置了值:-
$('#Location').val('xyz');
在HTTPPOST上,我有以下代码:-
[HttpPost]
public ActionResult Location(FormCollection form, Location mod)
{
string getLocation = mod.Location;
string getLocation1 = form["FromEsiLocation"];
// Both these methods are unable to retrieve the value which is set by jQuery
}
如何获取此值?禁用的文本框或任何其他字段的值永远无法发布,但您可以使用解决方法,只需为位置设置隐藏字段,并设置其值,然后在发布控制器操作时获取隐藏字段#Location
值
@Html.TextBoxFor(model => model.Location, new { @disabled = "disabled", @id="MyLocation" })
@Html.HiddenFor(model => model.Location) //take one more hidden field.
我可以用什么元素来代替文本框
?