Javascript 是否正在html.textboxfor()中获取值?
我的aspx中有这个:Javascript 是否正在html.textboxfor()中获取值?,javascript,json,asp.net-mvc-3,Javascript,Json,Asp.net Mvc 3,我的aspx中有这个: <div class="col2-input" id="Launch-Height-value"> <input type="hidden" name="Launch-Height" id="Launch-Height" value="<%: Model.LaunchHeight %>" /> <%: Html.TextBoxFor(model => model.LaunchHeight) %> </
<div class="col2-input" id="Launch-Height-value">
<input type="hidden" name="Launch-Height" id="Launch-Height" value="<%: Model.LaunchHeight %>" />
<%: Html.TextBoxFor(model => model.LaunchHeight) %>
</div>
<div class="col3">
<div id="save-launch-height">
<a href="javascript:saveLaunchHeight();" class="button">Save</a>
</div>
</div>
在视图中,我可以更改宽度值并单击保存,它会更新html.textboxfor,但仅此而已
然后httpget进入控制器
[HttpGet]
[NoCache]
public JsonResult UpdateLaunchWidth(int scormModuleId, short value)
{
if (value > 0)
{
var module = ZincService.ScormService.GetScormModule(scormModuleId);
if (module != null)
{
try
{
module.LaunchWidth = value;
ZincService.ScormService.UpdateScormModuleSettings(module);
ZincService.SaveChanges();
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
Logger.Error(ex, "Error setting new value for LaunchWidth property for scorm module with Id " + scormModuleId);
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}
}
else
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}
else
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}
这不会保存我的新值。我没有写这段代码,所以不能对它的工作原理做太多的改变。。如果我能在html.textboxfor中得到值。。。
请帮忙
谢谢不用太担心,我整理好了谢谢
function updateSaveButtons() {
if ($("#LaunchWidth").val() != $("#PassScoreHidden").val())
$("#save-pass-score-button").show();
}
[HttpGet]
[NoCache]
public JsonResult UpdateLaunchWidth(int scormModuleId, short value)
{
if (value > 0)
{
var module = ZincService.ScormService.GetScormModule(scormModuleId);
if (module != null)
{
try
{
module.LaunchWidth = value;
ZincService.ScormService.UpdateScormModuleSettings(module);
ZincService.SaveChanges();
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
Logger.Error(ex, "Error setting new value for LaunchWidth property for scorm module with Id " + scormModuleId);
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}
}
else
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}
else
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}