我的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>
<div class="col3">
<div id="save-launch-height">
<a href="javascript:saveLaunchHeight();" class="button">Save</a>
</div>
</div>
saveLaunchHeight:
function saveLaunchHeight() {
$("#Launch-Height").val($("#Launch-Height").val());
updateSaveButtons();
var jqxhr = $.getJSON("<%= Url.Action("UpdateLaunchHeight", "Scorm", new { area = "Admin" }) %>?scormModuleId=<%: Model.ScormModuleId %>&value=" + $("#Launch-Height").val(), function (data) {
alert($("#Launch-Height").val($("#Launch-Height").val()));
});
}
然后updateSaveButtons:
function updateSaveButtons() {
if ($("#LaunchWidth").val() != $("#PassScoreHidden").val())
$("#save-pass-score-button").show();
}
在视图中我可以更改宽度值并单击“保存”并更新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中获取值... 请帮忙吗?
感谢