2011-01-13 11 views
1

Ich habe eine "create" -Ansicht erstellt, um einen neuen Datensatz zu erstellen. Diese Ansicht sollte ein Bild beim Erstellen eines neuen Datensatzes hochladen können.Create-View mit Bild-Upload

Ich habe ein Formular zum Übermitteln von Werten erstellt, aber wenn ich ein zweites Formular im aktuellen Formular (mit einem eigenen Absenden) für das Hochladen von Bildern erstellen, funktioniert die Übergabeschaltfläche für das zweite Formular nicht.

Vielleicht haben Sie eine Idee?

create.cshtml

@model Portal.Models.Portal_Auftrag 
@{ 
    ViewBag.Title = "Create"; 
    Layout = "~/Views/Shared/_Layout.cshtml"; 
} 
<script type="text/javascript"> 
    $(function() { 
     $("#tabs").tabs(); 
     $("#DatumErstZul").datepicker({ dateFormat: 'dd.mm.yy' }); 
     $("#Schaden_Datum").datepicker({ dateFormat: 'dd.mm.yy' }); 
    }); 
</script> 
@using (Html.BeginForm()) 
{ 
    @Html.ValidationSummary(true) 

    <div id="tabs"> 
     <ul> 
      <li><a href="#tabs-5">Bild Unfallschaden</a></li> 
     </ul> 
     <div id="tabs-5"> 
      @Html.Action("WebAuftragUpload", ViewContext.RouteData.Values["Controller"].ToString(), new { id = ViewBag.AuftragGUID }) 
     </div> 
    </div> 
    <p> 
     <input type="submit" name="submit_auftrag" value="Auftrag senden" /> 
    </p> 

} 
<div> 
    @Html.ActionLink("Back to List", "Index") 
</div> 

Teilansicht:

<script type="text/javascript"> 
$(function() { 
    $("#ajaxUploadForm").ajaxForm({ 
     iframe: true, 
     dataType: "json", 
     beforeSubmit: function() { 
      $("#ajaxUploadForm").block({ message: '<h1><img src="/Content/jquery/busy.gif" /> Datei wird hochgeladen...</h1>' }); 
     }, 
     success: function (result) { 
      $("#ajaxUploadForm").unblock(); 
      $("#ajaxUploadForm").resetForm(); 
      $.growlUI(null, result.message); 
     }, 
     error: function (xhr, textStatus, errorThrown) { 
      $("#ajaxUploadForm").unblock(); 
      $("#ajaxUploadForm").resetForm(); 
      $.growlUI(null, 'Fehler beim hochladen der Datei'); 
     } 
    }); 
}); 
</script> 
@using (Html.BeginForm("AjaxWebUpload", ViewContext.RouteData.Values["Controller"].ToString(), FormMethod.Post, new { id = "ajaxUploadForm", enctype = "multipart/form-data" })) 
{ 
    <input type="hidden" name="id" value="@ViewBag.AuftragGUID" /> 
    <input type="file" name="file" /> 
    <input id="ajaxUploadButton" type="submit" name="submit_file" value="Datei hochladen" /> 

} 

Antwort

0

Sie sind not allowed nisten <form> Elemente. Dies ist ungültiges HTML und führt zu undefiniertem Verhalten. Sie sollten das zweite Formular außerhalb des ersten Formulars platzieren.

+0

Vielen Dank. Das war das Problem. – float

Verwandte Themen