0
當我按下按鈕一次,我想開始上傳和保存。我知道使用兩個不同的按鈕來工作兩個功能,一個是上傳,另一個是保存。任何建議?此代碼適用於每個函數有兩個按鈕。這是代碼。提前致謝。一鍵兩功能,保存並上傳
@model MvcMovie.Models.Movie
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Movie</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Title)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Title)
@Html.ValidationMessageFor(model => model.Title)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ReleaseDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ReleaseDate)
@Html.ValidationMessageFor(model => model.ReleaseDate)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Genre)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Genre)
@Html.ValidationMessageFor(model => model.Genre)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Price)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Price)
@Html.ValidationMessageFor(model => model.Price)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Rating)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Rating)
@Html.ValidationMessageFor(model => model.Rating)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ImageUrl)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ImageUrl)
@Html.ValidationMessageFor(model => model.ImageUrl)
</div>
<input type="submit" value="Create" />
</fieldset>
<img src="~/Content/Images/Full/i1.JPG" alt="Sample Image" width="300px" height="200px" />
<!--proba-->
}
@using (Html.BeginForm("Upload", "Movies", FormMethod.Post, new { enctype="multipart/form-data" }))
{
<input name="ImageUploaded" type="file">
<input type="submit" value="Upload"/>
}
<!--/proba-->
@Html.ActionLink("Back to List", "Index")
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
什麼不工作?你可以說得更詳細點嗎? –
當我嘗試使用ajax時,mvc報告錯誤...有沒有其他方法可以寫這段代碼,也許是因爲我在寫問題時使用了html標記? – nes
我建議你仔細閱讀本教程,以確保你擁有所有Ajax正常工作所需的組件。 http://msdn.microsoft.com/en-us/library/dd381533(v=vs.100).aspx –