我创建了一个“创建”视图来创建新记录。此视图应该能够在创建新记录时上传图片。
我已经创建了一个用于提交值的表单,但是当我在当前表单中创建第二个表单(使用自己的提交按钮)进行图片上传时,第二个表单的提交按钮不起作用。
也许你有个主意?
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>
局部视图:
<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" />
}