2012-06-04 3 views
0

MVC3 (VB.NET)으로 만들어진 시스템을 가지고있어 잘 작동합니다. 이 시스템을 MVC4 (Beta)로 업그레이드하려고하는데 HttpPost를 제외한 모든 것이 잘 작동합니다. 여기 MVC4 HttpPost not firing

뷰 코드 (면도칼)입니다 :

<HttpPost()> _ 
    Function Create(<Bind(Exclude:="IDCertificado, IDAsegurado")> ByVal parCertificadoAPG As Global.iSAM.Certificados) As ActionResult 

할 일 최종 기능

그러나 MVC4되어 있지 않을 경우 :

@Using Html.BeginForm() 

    @<fieldset> 
     <legend></legend> 
     <br /> 

     <fieldset> 
      <legend>Datos Generales</legend> 
      <table> 
       <tr> 
        <td style="border-width:0px; border-style:solid"> 
         @Html.LabelFor(Function(Model) Model.IDCertificado) 
         @Html.TextBox("ID_CERTIFICADO1", "Automático", New With {.readonly = "readonly", .style = "width:90px; text-align:center", .class = "letraingreso"}) 
        </td> 
        <td style="width:20px"></td> 
        <td style="border-width:0px; border-style:solid"> 
         @Html.LabelFor(Function(Model) Model.IDPoliza) 
         @Html.DropDownListFor(Function(Model) Model.IDPoliza, Nothing, New With {.style = "width:200px; visibility:visible", .class = "letraingreso"}) 
        </td> 
       </tr> 
       <tr> 
        <td style="border-width:0px; border-style:solid"> 
         @Html.LabelFor(Function(Model) Model.IDCampaña) 
         @Html.DropDownListFor(Function(Model) Model.IDCampaña, Nothing, New With {.style = "width:250px; visibility:visible", .class = "letraingreso"}) 
        </td> 
        <td style="width:20px"></td> 
        <td style="border-width:0px; border-style:solid"> 
         @Html.LabelFor(Function(Model) Model.IDVigencia) 
         @Html.DropDownListFor(Function(Model) Model.IDVigencia, Nothing, New With {.style = "width:183px; visibility:visible", .class = "letraingreso", .disabled = "disabled"}) 
        </td> 
       </tr> 
      </table> 
     </fieldset> 
     <br /> 

     <fieldset> 
      <legend>Datos del Certificado</legend> 
      <table width="99%"> 
       <tr> 
        <td style="border-width:0px; border-style:solid; width:8%"> 
         @Html.LabelFor(Function(Model) Model.FechaEmision) 
        </td> 
        <td style="border-width:0px; border-style:solid; width:11%"> 
         @Html.TextBox("FechaEmision", Nothing, New With {.style = "width:80px; text-align:center", .class = "letraingreso", .readonly = "readonly"}) 
        </td> 
        <td style="width:1%"></td> 
        <td style="border-width:0px; border-style:solid; width:8%"> 
         @Html.LabelFor(Function(Model) Model.FechaInicioVigencia) 
        </td> 
        <td style="border-width:0px; border-style:solid; width:12%"> 
         @Html.TextBoxFor(Function(Model) Model.FechaInicioVigencia, New With {.maxLength = "10", .onkeyup = "DateFormat(this, this.value, event, false, '3')", .onblur = "DateFormat(this, this.value, event, true, '3')", .style = "width:80px", .class = "letraingreso"}) 
         <a href="#"><img src="@Url.Content("~/Images/spacer.gif")" class="imagenfecha" style="border:0" height="16px" width="20px" id="imgFechaInicioVigencia" alt="" /></a> 
         <script type="text/javascript"> 
          Calendar.setup(
          { 
           inputField: "FechaInicioVigencia", 
           ifFormat: "%d/%m/%Y", 
           button: "imgFechaInicioVigencia", 
           align: "Tl", 
           singleClick: true 
          }); 
         </script> 
        </td> 
        <td style="width:1%"></td> 
        <td style="border-width:0px; border-style:solid; width:25%"> 
         @Html.LabelFor(Function(Model) Model.FechaFinVigencia) 
         @Html.TextBoxFor(Function(Model) Model.FechaFinVigencia, New With {.maxLength = "10", .onkeyup = "DateFormat(this, this.value, event, false, '3')", .onblur = "DateFormat(this, this.value, event, true, '3')", .style = "width:80px", .class = "letraingreso"}) 
         <a href="#"><img src="@Url.Content("~/Images/spacer.gif")" class="imagenfecha" style="border:0" height="16px" width="20px" id="imgFechaFinVigencia" alt="" /></a> 
         <script type="text/javascript"> 
          Calendar.setup(
          { 
           inputField: "FechaFinVigencia", 
           ifFormat: "%d/%m/%Y", 
           button: "imgFechaFinVigencia", 
           align: "Tl", 
           singleClick: true 
          }); 
         </script> 
        </td> 
       </tr> 

       <tr> 
        <td style="border-width:0px; border-style:solid; width:8%"> 
         @Html.LabelFor(Function(Model) Model.IDEstado) 
        </td> 
        <td style="border-width:0px; border-style:solid; width:11%"> 
         @Html.DropDownListFor(Function(Model) Model.IDEstado, Nothing, New With {.style = "width:100px; visibility:visible", .class = "letraingreso", .disabled = "disabled"}) 
        </td> 
        <td style="width:1%"></td> 
        <td colspan="5" style="border-width:0px; border-style:solid; width:13%"> 
         @Html.LabelFor(Function(Model) Model.IDPlanGrupoCobertura) 
         @Html.DropDownListFor(Function(Model) Model.IDPlanGrupoCobertura, Nothing, New With {.style = "width:350px; visibility:visible", .class = "letraingreso"}) 
        </td> 
       </tr> 
      </table> 
     </fieldset> 
     <br /> 

     <div id="tabs"> 
      @*Establece los tabs a ser creados*@ 
      <ul> 
       <li><a href="#fragment-1"><span>Asegurado</span></a></li> 
      </ul> 

      @*Asegurados*@ 
      <div id="fragment-1"> 
       <table> 
        <tr> 
         <td style="border-width:0px; border-style:solid; width:58px"> 
          @Html.LabelFor(Function(Model) Model.IDAsegurado) 
         </td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.TextBox("IDAsegurado", "Automático", New With {.readonly = "readonly", .style = "width:80px; text-align:center", .class = "letraingreso"}) 
         </td> 
         <td style="width:10px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.IDTipoDocumentoAsegurado) 
          @Html.DropDownListFor(Function(Model) Model.IDTipoDocumentoAsegurado, Nothing, New With {.style = "width:200px; visibility:visible", .class = "letraingreso"}) 
         </td> 
         <td style="width:10px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.NumeroDocumentoAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.NumeroDocumentoAsegurado, New With {.onkeyup = "if(this.value.match(/\D/))this.value=this.value.replace(/\D/g,'')", .class = "letraingreso", .style = "width:100px"}) 
         </td> 
         <td style="width:10px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.FechaNacimientoAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.FechaNacimientoAsegurado, New With {.maxLength = "10", .onkeyup = "DateFormat(this, this.value, event, false, '3')", .onblur = "DateFormat(this, this.value, event, true, '3')", .style = "width:80px", .class = "letraingreso"}) 
          <a href="#"><img src="@Url.Content("~/Images/spacer.gif")" class="imagenfecha" style="border:0" height="16px" width="20px" id="imgFechaNacimientoAsegurado" alt="" /></a> 
          <script type="text/javascript"> 
           Calendar.setup(
           { 
            inputField: "FechaNacimientoAsegurado", 
            ifFormat: "%d/%m/%Y", 
            button: "imgFechaNacimientoAsegurado", 
            align: "Tl", 
            singleClick: true 
           }); 
          </script> 
         </td> 
        </tr> 
       </table> 
       <table> 
        <tr> 
         <td style="border-width:0px; border-style:solid; width:58px"> 
          @Html.LabelFor(Function(Model) Model.NombresAsegurado) 
         </td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.TextBoxFor(Function(Moel) Model.NombresAsegurado, New With {.style = "text-transform:uppercase; width:270px", .class = "letraingreso"}) 
         </td> 
         <td style="width:15px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.PrimerApellidoAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.PrimerApellidoAsegurado, New With {.style = "text-transform:uppercase; width:182px", .class = "letraingreso"}) 
         </td> 
         <td style="width:15px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.SegundoApellidoAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.SegundoApellidoAsegurado, New With {.style = "text-transform:uppercase; width:182px", .class = "letraingreso"}) 
         </td> 
        </tr> 
       </table> 
       <table> 
        <tr> 
         <td style="border-width:0px; border-style:solid; width:58px"> 
          @Html.LabelFor(Function(Model) Model.IDCiudadAsegurado) 
         </td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.DropDownListFor(Function(Model) Model.IDCiudadAsegurado, Nothing, New With {.style = "width:180px; visibility:visible", .class = "letraingreso"}) 
         </td> 
         <td style="width:15px"></td> 

         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.IDGeneroAsegurado) 
          @Html.DropDownListFor(Function(Model) Model.IDGeneroAsegurado, Nothing, New With {.style = "width:98px; visibility:visible", .class = "letraingreso"}) 
         </td> 
        </tr> 
       </table> 
      </div> 

     </div> 

     <br /> 
     <fieldset> 
      <legend>Observaciones</legend> 
      @Html.LabelFor(Function(Model) Model.Observaciones) 
      @Html.TextBoxFor(Function(Model) Model.Observaciones, New With {.class = "letraingreso", .style = "width:90%; text-transform:uppercase"}) 
     </fieldset> 
    </fieldset> 

    @<div style="display:none; position:absolute; margin:auto; left:0; right:0; text-align:center" id="inprogress"> 
     <br /><br /><br /><br /><br /><br /> 
     <img id="inprogress_img" src="@Url.Content("~/Images/loading.gif")" alt="Procesando..." /> 
     <br /> 
     Por favor espere mientras su solicitud es procesada... 
    </div> 

    @<p> 
     <input type="submit" value="Guardar" id="cmdGuardar" onclick="return doSubmit()" /> 
    </p> 

    @<div> 
     @Html.ActionLink(" ", "ListarCertificadosAPG", "CertificadosLayout", New With {.area = ""}, New With {.class = "imgRegresar", .title = "Regresar"}) 
    </div> 
End Using 

나는 MVC3에서, 버튼 인상 컨트롤러를 제출 말했듯 HttpPost 발사. 내가보기 코드에서를 사용 종료 후 (단지 예와 같이) 다음 코드를 삽입 :

@Using Html.BeginForm() 
    @<input type="submit" value="SSS" /> 
End Using 

내가 SSS 버튼을 누를 때 그것은 HttpPost를 올립니다. 실수 나 오류가 어디에서 발생했는지 이해하거나 해결하는 데 도움을 줄 수 있습니까?

감사합니다.

+0

첫 번째 샘플에서는 제출 버튼의 클릭 이벤트가 JS에 의해 무시됩니다. 'doSubmit()'함수의 코드를 게시 할 수 있습니까? – nemesv

답변

1

몇 가지 테스트를 한 후에 제출하지 않는 이유를 찾았습니다. 내 MainLayout에 나는 선언있어했습니다

<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script> 

나는이 라인을 주석하고 작품을 제출했다. 그러나 왜이 줄을 제출 제출 작동하지 않는지 모르겠다.

나는 MVC4 RC를 설치하고 지금은이 3 선 댓글을 달았 :

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" /> 
<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/themes/base/css")" rel="stylesheet" type="text/css" /> 
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script> 

내가 선 할 thease 것을 알고 깊은 MVC4를 검토해야합니다. 모두들 감사합니다.

+0

동일한 문제가 있습니다. 그러나, 위의 코드는 내 코드에서 볼 수 없습니다. '@ scripts.Render ("~/bundles/jqueryval")'에 주석을 달고 나면, HttpPost가 나를 위해 일하고있다. 이 라인이 왜이 문제를 일으키는 지 더 자세히 조사해야합니다. 고맙습니다! – rk1962