2011-03-17 44 views
1

我有一個奇怪的問題。我用它控制器創建和編輯視圖。一切工作正常,但(例如)如果我沒有輸入值,驗證@ Html.ValidationSummary(False)返回消息錯誤。問題在於,當瀏覽器凍結並消耗大量資源(內存)時出現錯誤,但在等待4或5分鐘後,視圖將顯示數據和驗證消息。MVC視圖凍結

服務器是:Windows 2003標準版,SQLServer 2008標準版,IIS6.0。 在開發環境中,這是同樣的問題。 我使用VS2010 SP1和剃鬚刀和MVC3。這個問題在VS2008 SP1中也出現了aspx和MVC2。

有人知道它是怎麼回事?

問候。


因爲它是減少代碼也許有一個錯誤,但原來它很好。當然,所有的JavaScript和jQuery調用退出

編輯觀點

@ModelType iSAM.Certificados 

@Code 
ViewData("Title") = "Edit" 
Layout = "~/Views/Shared/CertificadosLayout.vbhtml" 
End Code 

@section Contenido 
@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.TextBoxFor(Function(Model) Model.IDCertificado, 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 /> 

     <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"> 
          @Html.LabelFor(Function(Model) Model.IDAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.IDAsegurado, New With {.readonly = "readonly", .style = "width:80px; text-align:center", .class = "letraingreso"}) 
         </td> 
         <td style="width:20px"></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:20px"></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:20px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.FechaNacimientoAsegurado) 
          @Html.TextBox("FechaNacimientoAsegurado", Format(Model.FechaNacimientoAsegurado, "dd/MM/yyyy"), 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"> 
          @Html.LabelFor(Function(Model) Model.NombresAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.NombresAsegurado, New With {.style = "text-transform:uppercase; width:270px", .class = "letraingreso"}) 
         </td> 
         <td style="width:20px"></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:20px"></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"> 
          @Html.LabelFor(Function(Model) Model.IDCiudadAsegurado) 
          @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.DireccionDomicilioAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.DireccionDomicilioAsegurado, New With {.style = "text-transform:uppercase; width:354px", .class = "letraingreso"}) 
         </td> 
         <td style="width:20px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.CorreoElectronicoAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.CorreoElectronicoAsegurado, New With {.class = "letraingreso", .style = "width:170px"}) 
         </td> 
        </tr> 
       </table> 
       <table> 
        <tr> 
         <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> 
         <td style="width:15px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.IDEstadoCivilAsegurado) 
          @Html.DropDownListFor(Function(Model) Model.IDEstadoCivilAsegurado, Nothing, New With {.style = "width:120px; visibility:visible", .class = "letraingreso"}) 
         </td> 
         <td style="width:15px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.TelefonoFijoAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.TelefonoFijoAsegurado, New With {.class = "letraingreso", .style = "width:80px", .onkeydown = "javascript:return dFilter (event.keyCode, this, '###-##-####');"}) 
         </td> 
         <td style="width:15px"></td> 
         <td style="border-width:0px; border-style:solid"> 
          @Html.LabelFor(Function(Model) Model.TelefonoCelularAsegurado) 
          @Html.TextBoxFor(Function(Model) Model.TelefonoCelularAsegurado, New With {.class = "letraingreso", .style = "width:80px", .onkeydown = "javascript:return dFilter (event.keyCode, this, '###-##-####');"}) 
         </td> 
        </tr> 
       </table> 
       <br /> 
      </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(" ", "ListarCertificadosVehiculos", "CertificadosLayout", New With {.area = ""}, New With {.class = "imgRegresar", .title = "Regresar"}) 
    </div> 
End Using 
End Section 

類(記住這是一個減少代碼)

Imports System.ComponentModel 
Imports System.ComponentModel.DataAnnotations 

Public Class Certificados 
Private varIDCertificado As Long 
Private varIDPoliza As Long 
Private varNumeroPoliza As Long 
Private varIDCampaña As Long 
Private varIDVigencia As Long 

<DisplayName("Número de Certificado:")> _ 
Public Property IDCertificado() As Long 
    Get 
     Return varIDCertificado 
    End Get 

    Set(ByVal value As Long) 
     varIDCertificado = value 
    End Set 
End Property 

<Required(ErrorMessage:="Debe seleccionar la poliza correspondinete")> _ 
<DisplayName("Número de Poliza:")> _ 
Public Property IDPoliza() As Long 
    Get 
     Return varIDPoliza 
    End Get 

    Set(ByVal value As Long) 
     varIDPoliza = value 
    End Set 
End Property 

<DisplayName("Número de Poliza:")> _ 
Public Property NumeroPoliza() As Long 
    Get 
     Return varNumeroPoliza 
    End Get 

    Set(ByVal value As Long) 
     varNumeroPoliza = value 
    End Set 
End Property 
End Class 

服務(如果返回FALSE的問題,我出現)

Public Function EditarCertificadoVehiculo(ByVal parCertificado As CERTIFICADO, ByVal parIDTarjetaCredito As String, ByVal parIDEstado As Long, _ 
              ByVal parLugarTrabajoAsegurado As LUGAR_DE_TRABAJO, ByVal parIDCiudadLugarTrabajo As Long, ByVal parLugarTrabajoPagador As LUGAR_DE_TRABAJO, ByVal parIDCiudadLugarTrabajoPagador As Long, _ 
              ByVal parAsegurado As ASEGURADO, ByVal parIDTipoDocumento As Long, ByVal parIDCiudadNacimiento As Long, ByVal parIDGenero As Long, ByVal parIDEstadoCivil As Long, _ 
              ByVal parPagador As ASEGURADO, ByVal parIDTipoDocumentoPagador As Long, ByVal parIDCiudadNacimientoPagador As Long, ByVal parIDGeneroPagador As Long, ByVal parIDEstadoCivilPagador As Long, _ 
              ByVal parConductor As CONDUCTOR, _ 
              ByVal parConcesionario As CONCESIONARIO, _ 
              ByVal parVehiculo As VEHICULO, ByVal parIDMarca As Long, ByVal parIDModelo As Long, ByVal parIDTipoPlaca As Long, ByVal parIDUsoVehiculo As Long, ByVal parIDColor As Long, _ 
              ByVal parArregloTasas As ArrayList, ByVal parArregloExtras(,) As String) As Boolean Implements IiSAMService.EditarCertificadoVehiculo 

    If Not ValidarCertificadoVehiculo(parCertificado, parIDTarjetaCredito, parAsegurado, parLugarTrabajoAsegurado, parPagador, parLugarTrabajoPagador, parVehiculo, parIDTipoPlaca, parConcesionario, parArregloTasas, parIDEstado) Then 
     Return False 
    End If 

    Try 
     varRepositorio.EditarCertificadoVehiculo(parCertificado, parIDTarjetaCredito, parIDEstado, _ 
               parLugarTrabajoAsegurado, parIDCiudadLugarTrabajo, parLugarTrabajoPagador, parIDCiudadLugarTrabajoPagador, _ 
               parAsegurado, parIDTipoDocumento, parIDCiudadNacimiento, parIDGenero, parIDEstadoCivil, _ 
               parPagador, parIDTipoDocumentoPagador, parIDCiudadNacimientoPagador, parIDGeneroPagador, parIDEstadoCivilPagador, _ 
               parConductor, _ 
               parConcesionario, _ 
               parVehiculo, parIDMarca, parIDModelo, parIDTipoPlaca, parIDUsoVehiculo, parIDColor, _ 
               parArregloTasas, parArregloExtras) 
    Catch ex As Exception 
     varDiccionarioValidacion.AddError("EditarCertificadoVehiculo", ex) 
     Return False 
    End Try 
    Return True 
End Function 
+0

你能分享一些代碼嗎?最好是您的表單和提交給它的操作方法。 – 2011-03-17 22:23:15

回答

0

好的。我試着用谷歌瀏覽器和瀏覽器凍結像IE8幾分鐘,但鉻不崩潰。所以我可以看到一個下拉列表加載了數千條記錄(可能是100000--我的錯誤)。

這是糾正行:

If String.IsNullOrEmpty(Request.Form("NombreLugarTrabajoAsegurado")) Then 
      varListado = New SelectList(varServicio.ListarLugaresTrabajoPorNombre("NO DEFINIDO", True, True), "ID_LUGAR_TRABAJO", "NOMBRE_LUGAR_TRABAJO") 
     Else 
      varListado = New SelectList(varServicio.ListarLugaresTrabajoPorNombre(Request.Form("NombreLugarTrabajoAsegurado"), True, True), "ID_LUGAR_TRABAJO", "NOMBRE_LUGAR_TRABAJO", Request.Form("IDLugarTrabajoAsegurado")) 
     End If 
     ViewData("IDLugarTrabajoAsegurado") = varListado 

也許IE團隊需要解決這個問題,以防止崩潰。 我希望這可以幫助別人。