Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145294 | Jun 16,2019 04:43 PM UTC | Aug 1,2019 12:11 AM UTC | ASP.NET MVC - EJ 2 | 11 |
![]() |
Tags: Uploader |
<form id="EmailRequestForm">
<div class="form-group" style="padding-top: 11px;">
<div class="e-float-input">
<input type="text" id="Recipient" name="Recipient">
<span class="e-float-line"></span>
<label class="e-float-text e-label-top" for="Recipient">Recipient</label>
</div>
</div>
<div class="form-group" style="padding-top: 11px;">
<div class="e-float-input">
<input type="text" id="MessageContent" name="MessageContent">
<span class="e-float-line"></span>
<label class="e-float-text e-label-top" for="MessageContent">MessageContent</label>
</div>
</div>
<div class="form-group" style="padding-top: 11px;">
<div class="e-float-input">
@Html.EJS().Uploader("FileUpload").AutoUpload(false).Multiple(false).Render()
</div>
</div>
<input type="button" class="submit-btn e-btn" id="btn" value="Post via AJAX" />
</form>
<script type="text/javascript">
$(function () {
$("#btn").click(function (e) {
var formdata = new FormData($("#EmailRequestForm")[0]);
$.ajax({
url: "@Url.Action("ProcessEmailrequest")",
data: formdata,
success: function (data) {
// Do something here when it is finished
},
type: 'POST',
cache: false,
contentType: false,
processData: false
});
e.stopPropagation();
});
});
</script> |
[HttpPost]
public ActionResult ProcessEmailrequest()
{
var recipient = Request["Recipient"];
var content = Request["MessageContent"];
var file = Request.Files["FileUpload"];
// Save the files and values to the database here
return View("Index");
} |
@Html.EJS().Uploader("FileUpload").AutoUpload(false).Multiple(false).AsyncSettings(new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = @Url.Content("https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save"), RemoveUrl = @Url.Content("https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove") }).Render() |
@Html.EJS().Uploader("FileUpload").AutoUpload(false).Multiple(false).Uploading("onFileUpload").Success("onSuccess").AsyncSettings(new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "http://localhost:61715/Home/Save", RemoveUrl = "http://localhost:61715/Home/Remove" }).Render() |
function onFileUpload(args) {
var Ageid = document.getElementById('Ageid').value;
var Agency = document.getElementById('Agency').value;
args.customFormData = [{ 'Id': Ageid }, { 'Agency': Agency} ];
} |
@Html.EJS().Uploader("FileUpload").AutoUpload(false).Multiple(false).Uploading("onFileUpload").Success("onSuccess").AsyncSettings(new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "http://localhost:61715/Home/Save", RemoveUrl = "http://localhost:61715/Home/Remove" }).Render()
. . . . . . .
<script>
. . . . . . .
function onSuccess(args) {
document.getElementById('Ageid').value = null;
document.getElementById('Agency').value = null;
}
. . . . . . . .
</script> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.