Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否正在html.textboxfor()中获取值?_Javascript_Json_Asp.net Mvc 3 - Fatal编程技术网

Javascript 是否正在html.textboxfor()中获取值?

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) %> </

我的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>
在视图中,我可以更改宽度值并单击保存,它会更新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);
}