MVC4多按钮形式不起作用JQM

Ste*_*hot 8 c# asp.net-mvc jquery-mobile asp.net-mvc-4

我在MVC4中面对我的JQuery移动APP上的一个奇怪的问题:

我有一个像这样的几个texbox的表单

@using Models
@model Models.DataModel.Pagina_Details
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}


@using (Html.BeginForm("Pagina_Details", "Home", FormMethod.Post, new { id =          "PaginaDetailsForm" }))
{
if (Request.QueryString["Command"] != null)
{
    Session["Command"] = Request.QueryString["Command"];
}
else
{
    Response.Redirect("Index");
}
<div class="ui-corner-all custom-corners ui-shadow">
  <div class="ui-bar ui-bar-a">
    <h3>Pagina's</h3>
  </div>
<div class="ui-body ui-body-a">
 <input type="hidden" id="Command" />
  @Html.HiddenFor(model => model.ID)
 @Html.LabelFor(model => model.Name, "Naam *", new { @class = "lbl"})    
 @Html.TextBoxFor(model => model.Name, new { required = "required" })

 @Html.LabelFor(model => model.Description, "Omschrijving *", new { @class = "lbl"})    
 @Html.TextArea("Description", new { required = "required", rows="10", cols="80"})

 @Html.LabelFor(model => model.MetaDescription, "Meta description", new { @class =  "lbl" })    
 @Html.TextBoxFor(model => model.MetaDescription)

 @Html.LabelFor(model => model.MetaKeywords, "Meta keywords", new { @class = "lbl" })    
 @Html.TextBoxFor(model => model.MetaKeywords)

 @Html.LabelFor(model => model.Active, "Actief", new { @class = "lbl" })   
 @Html.CheckBoxFor(model => model.Active)

@if (Session["Command"] == "Insert" || Request.QueryString["Command"] == "Insert")
{
    <button type="submit" name="Command" data-role="button" data-icon="plus">Toevoegen</button>
}       
@if (Session["Command"] != "Insert" && Request.QueryString["Command"] != "Insert")
{
    <button type="submit" id="Edit" name="Command" value="Opslaan" data-role="button" data-icon="edit">Opslaan</button>
    <button type="submit" id="Verwijderen" name="Command" value="Verwijderen" data-role="button" data-icon="delete">Verwijderen</button>
}

</div>

</div>

}
Run Code Online (Sandbox Code Playgroud)

在我的ActionResult(控制器)我有param命令,并在交换机中使用它来做它的问题在桌面浏览器上运行良好,我可以看到命令传递给ActionResult一切正常,因为它应该但由于某些原因,当我在手机上使用Phonegap尝试同样的事情时,Command值将始终为null

尝试了什么:AttributeUsage 如何在ASP.NET MVC框架中处理多个提交按钮? 根本没有结果.

我也为2个按钮尝试了不同的ActionResults,根本没有结果.

我失去了有人知道一些提示或有任何想法如何我可以解决这个问题.你的时间和帮助.

小智 1

这可能不是您想要的,但为什么不使用按钮作为 JavaScript 函数,它可以在提交之前更改表单的操作。我认为这是保持逻辑清晰和简单修复的好方法。因为你使用phonegap javascript 应该不是问题。祝你好运!

<script type="text/javascript">
document.getElementById("edit").onclick = function() {
 a=document.getElementsByTagName("form")[0];
a.action ="URL for Edit";
a.submit();
 }
document.getElementById("Verwijderen").onclick = function() {
 a=document.getElementsByTagName("form")[0];
a.action ="URL for Verwijderen";
a.submit();
 }

</script>
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!-德鲁