Hello,
How do I get a value from a textbox " DescricaoGestor" and pass to controller when uploading?
Thanks
<div class="form-group col-md-8 textbox-row">
<ejs-textbox id="DescricaoGestor" floatLabelType=Always placeholder="Descrição"></ejs-textbox>
</div>
<div class="form-group col-md-4 textbox-row">
@{
var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = "/OrdemServico/UploadAtividadeInterna/" + Model.Id };
}
<div class="button-containerdetails" style="margin-bottom:20px;">
<div class="button-left" style="margin-right:30px;">
<ejs-uploader id="uploadFiles" locale="pt" allowedExtensions=".*"
asyncSettings="@asyncSettings" autoUpload="false" Success="SuccessHandler"></ejs-uploader>
</div>
</div>
</div>
public void UploadAtividadeInterna(IList<IFormFile> UploadFiles, long id, string DescricaoGestor)
{
try
{
foreach (var file in UploadFiles)
{
if (file != null)
{
}
}
}
catch (Exception e)
{
Response.Clear();
Response.StatusCode = 204;
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "Falha no upload";
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message;
}
}
Hi Fernando,
Thank you for reaching out to us. We have created a sample based on your requirements, which involves passing the textbox value to the server using the setRequestHeader method in the uploading event, and then retrieving this value in the server-side controller.
Below is the code snippet for your reference:
|
[index.cshtml] <ejs-uploader
id="UploadFiles" asyncSettings="@asyncSettings"
removing="onFileRemove" uploading="uploadStart"></ejs-uploader>
} </script>
[UploaderController.cs]
public void
Save(IList<IFormFile> UploadFiles) ……
|
This code ensures that the value entered into the textbox is passed to the server-side controller through the Authorization header in the HTTP request. You can then retrieve this value in the controller using HttpContext.Request.Headers["Authorization"].
Regards,
Yohapuja S
Hi, it worked perfectly. Thank you very much!