<pre lang="HTML">@model SendAFaxWeb.Models.Send //view start here <body> <div> <h2>Test Upload File</h2> <form action="@Url.Action("Index", "Home")" id="form" method="post" enctype="multipart/form-data"> @Html.AntiForgeryToken() <div class="form-group"> <label>Fax Number:</label> @Html.TextBoxFor(m => m.Recipients[0].Number) </div> <div class="form-group"> <label>Select File:</label> <input type="file" name="files" id="file" multiple="multiple" onchange="this.form.submit();" /> </div> <div> @if (Model != null) { foreach (var item in Model.Documents) { <li>FileName: @item.Name</li> } } </div> </form> <input type="submit" name="send" value="Send" id="btnSend" /> </div> </body>
<script type="text/javascript"> $(document).ready(function () { $("#btnSend").click(function (e) { alert("button click"); e.preventDefault(); var model = @Html.Raw(Json.Encode(Model)) $.ajax({ type: 'post', url: '@Url.Action("Send", "Home")', data: JSON.stringify({ contact: model }), contentType: 'application/json; charset=utf-8', dataType: "json", success: function (data) { alert(data); } }); }); }); </script>
public ActionResult Send(Send contact) { //some code here }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)