Reputation: 482
I've a system made in MVC3 (VB.NET) and it's work fine. I'm trying to upgrade this system to MVC4 (Beta), and everything work fine except for HttpPost.
Here's the view code (razor):
@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
As I said, in MVC3, submit button raise controller:
<HttpPost()> _
Function Create(<Bind(Exclude:="IDCertificado, IDAsegurado")> ByVal parCertificadoAPG As Global.iSAM.Certificados) As ActionResult
todo End Function
But in MVC4 not firing HttpPost. I put the next code (just like example) after End Using in the view code:
@Using Html.BeginForm()
@<input type="submit" value="SSS" />
End Using
And when I press SSS button it raise the HttpPost. Can someone help me to solve or understand where is the mistake or error?
Regards.
Upvotes: 0
Views: 1647
Reputation: 482
After some tests, I found the reason why submit do not raising. On my MainLayout I've got declared:
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>
I had to comment this line and submit works. However I don't know why this line makes submit doesn't work.
I installed MVC4 RC and now I have commented this 3 lines:
<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>
I need to review deeper MVC4 to know what thease lines do. Regards everybody.
Upvotes: 1