Hi
My req is to save the documents in database in blob format. When user submits the form, the form will be saved in database and then with saved formid as reference key uploaded documents will be saved in documents table.
When user edits submitted form, I need to display already attached forms on the page. User may delete or attach new forms in edit screen.
When user viewing the form in read only mode, user should be able to download the form. How can i achieve this?
below code is working for uploading...
<div class="row col-md-12">
<div class="col-md-10">
<div class="form-group">
@Html.LabelFor(model => model.files, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
@(Html.Kendo().Upload()
.Name("files")
.Validation(validation => validation
.AllowedExtensions(new string[] { ".pdf", ".txt", ".xlsx", ".xls", ".doc", ".docx" })
.MaxFileSize(15728640)
.MinFileSize(3000))
.ShowFileList(true)
.HtmlAttributes(new { aria_label = "files" })
)
@Html.ValidationMessageFor(model => model.files, "", new { @class = "text-danger" })
</div>
</div>
</div>
</div>
viewmodel class
[Display(Name = "Upload relevant documents")]
public IEnumerable<HttpPostedFileBase> files { get; set; }
foreach (var file in vm.files)
{
byte[] document = new byte[file.ContentLength];
file.InputStream.Read(document, 0, file.ContentLength);
RLADOCUMENT rd = new RLADOCUMENT
{
RLAFORMID = (int)entity.ID,
DOCUMENTNAME = file.FileName,
CONTENTTYPE = file.ContentType,
DOCUMENTSIZE = document.Length,
DOCUMENTDATA = document,
CREATEDBY = Environment.UserName,
CREATEDDATE = DateTime.Now,
EXTENSION = Path.GetExtension(file.FileName)
};
_context.RLADOCUMENTS.Add(rd);
_context.SaveChanges();
}
Can someone help me how to display already attached files in Edit Mode with remove and upload option and download the attached reports.
How to display the "File(s) saved successfully in the Custom Kendo Upload Template.
Using the template below:
<span class='k-progress'></span>I'm using Kendo v 2023.2.606 from the Kendo CDN.
In my view I have the following code:
<div class="row row-cols-lg-auto gx-3 gy-2 align-items-baseline mt-2">
<div class="col">
<h4>Choose File</h4>
<!-- upload a file -->
@(Html.Kendo().Upload()
.Name("files")
.Multiple(false)
.ShowFileList(false)
.Async(_ => _
.Save("SubmitFile", "DataImport", new { Area = "Admin" })
.Batch(true)
.AutoUpload(true)
)
.Events(_ => _
.Upload("onUpload")
.Success("onUploadSuccess")
.Error("onUploadFail")
)
.Validation(_ => _
.AllowedExtensions(new string[] { "xls", "xlsx", "csv" })
.MaxFileSize(3145728)
)
)
</div>
</div>
If I select a file with an extension that is not listed, e.g. .zip, or I select a file that is more than 3.14MB all I see is this:
It does not hit my MVC controller action (which is fine) but the only indication of a problem is the (!) icon. The icon is not clickable.
Why is it not displaying a message saying the file is not valid/too big?
Has anyone else noticed that neither the .Net core or MVC upload module works when run under iOS? https://www.telerik.com/aspnet-core-ui/upload
If you try and upload anything you can never click submit.
You can try it on the demo here on any iOS device -
This seems to have broken when the move was made to go to Sass from Less a few months ago. It worked fine in Less. With it being such a major component it is something that you would hope gets fixed very quickly.
I have a form as follows where it fires validation for text box controls but not for file upload
<form id="frmItem">
<table class="table table-bordered">
<thead class="bg-dark text-center text-white">
<tr>
<th colspan="2">Add/Modify Item</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width:404px;">Item ID Name</td>
<td>
@(Html.Kendo().TextBox().Name("txtItemName")
.HtmlAttributes(new { placeholder = "Item ID Name", required = "required", validationmessage = "Enter Item ID Name" }))
</td>
</tr>
<tr>
<td>UN Number</td>
<td>
@(Html.Kendo().TextBox().Name("txtUnNumber")
.HtmlAttributes(new { placeholder = "UN Number", required = "required", validationmessage = "Enter UN Number" }))
</td>
</tr>
<tr>
<td>Packing Instructions</td>
<td>
@(Html.Kendo().TextBox().Name("txtPackingInstructions")
.HtmlAttributes(new { placeholder = "Packing Instructions", required = "required", validationmessage = "Enter Packing Instructions" }))
</td>
</tr>
<tr>
<td>SDS Sheet</td>
<td>
@(Html.Kendo().Upload().Name("SdsSheet")
.Multiple(false)
.HtmlAttributes(new { required = "required" }))
</td>
</tr>
<tr>
<td>Cargo Only?</td>
<td>@(Html.Kendo().CheckBox().Name("txtCargoOnly"))</td>
</tr>
<tr>
<td>Example Shipment Ground (Fully Regulated)</td>
<td>@(Html.Kendo().Upload().Name("GroundShipment"))</td>
</tr>
<tr>
<td>Example Shipment Next Day Air (Fully Regulated)</td>
<td>@(Html.Kendo().Upload().Name("NextDayShipment"))</td>
</tr>
<tr>
<td>Example Shipment Freight (Fully Regulated)</td>
<td>@(Html.Kendo().Upload().Name("FreightShipment"))</td>
</tr>
<tr>
<td>Example Shipment Ground (Limited Quantity)</td>
<td>@(Html.Kendo().Upload().Name("GroundShipmentLimited"))</td>
</tr>
<tr>
<td>Example Shipment Next Day Air (Limited Quantity)</td>
<td>@(Html.Kendo().Upload().Name("NextDayShipmentLimited"))</td>
</tr>
<tr>
<td>Example Shipment Freight (Limited Quantity)</td>
<td>@(Html.Kendo().Upload().Name("FreightShipmentLimited"))</td>
</tr>
<tr>
<td colspan="2">
<button class="k-button k-button-solid-primary k-button-solid k-button-md k-rounded-md" type="submit">Submit</button>
</td>
</tr>
</tbody>
</table>
</form>
<script>
$(document).ready(function () {
var validator = $("#frmItem").kendoValidator().data("kendoValidator");
$("#frmItem").submit(function (event) {
event.preventDefault();
if (validator.validate()) {
} else {
}
});
});
</script>
Good day,
i Just updated kendo ui mvc project to the latest version currently out yesterday. now its broken.
before upgrade
after upgrade
Hi,
I have a Html.Kendo().Upload()
I am open new popup window using following code
var objWin = $("#addWindowPopup"),
undo = $("#undo");
undo.click(function () {
objWin.data("kendoWindow").top().open();
undo.fadeOut();
});
objWin.kendoWindow({
width: "94%",
content: rootPath + "Workord/Popup?ispopup=1&eqinvid=" + eqinvid + "&wotype=" + wotype + "&controlno=" + controlno + "&mproc_id=" + mproc_id + "&mprocname=" + mprocname + "&procnum=" + procnum+"&freq=" + freq+"&occurs=" + occurs+"&freqname=" + freqname+"&nextdate=" + nextdate,
height: "710px",
visible: false,
close: onClose,
iframe: true,
model: true,
}).data("kendoWindow").open();
In popup I used Kendo().Upload() to save uploaded file in database but if I am upload file first time it save twice in database.
How to resolve this issue
My web application's implementation of the Upload widget does data validation through the component itself (max file size, allowed file types, etc.) as well as some extra validation through the Async.Save() handler's controller action (image validity, checking for animated images, etc.). It's my understanding that there are three potential results from the handler:
During the non-client side validation in my controller, should one of the checks fail we call "return Content(<string>)" and for the most part, this works as intended if the string contains any non-numeric characters. Initially I was simply returning a reference to a resource string defining the error and displaying it to the user in an alert describing what went wrong with the upload (via XMLHttpRequest.responseText); however, in the case of an undefined (by me) error this would result in an alert showing server response details that I don't wish to be displayed to the user. Thus I decided to send error codes and translate those client-side. This made it much easier to check for the error messages I mean to display to the user as well as have a default that displays for any unintended response. My problem is that if I return a string that is strictly numeric the handler doesn't result in an error.
Ex. return Content("Error: Bad File") would result in my error handler being called, and the text "Error: Bad File" being displayed in an alert.
But return Content("2") would result in a "successful" upload. The amount of numbers in the string doesn't matter, but if at any point a letter or symbol is included in the string it once again properly handles as an error.
I've already fixed my code to work by adding "error" into the string with the code number but I figured it was worth asking about since I would prefer to just use a numeric string. I'm puzzled as to what is causing the issue, as I don't believe strings containing only numbers are treated any differently than others unless they're being parsed. If I check the network response in the dev. console it shows the string as the response, which is what leads me to think it's something with the kendo widget.
Using .NET Framework 4.7.2, ASP.NET MVC 4 and Kendo.Mvc version 2021.2.616.545.