1

我的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>

保存启动高度:

   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()));
   });
 }

然后更新保存按钮:

  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 中的值...请帮忙?

谢谢

4

0 回答 0