I have read all (most of) the entries in this forum regarding this matter and cannot seem to find my error. I want to upload a single file that I then pass onto another system. As multiple users could upload at the same time I use a GUID as a message ID and create a folder per user. Here I get the document (from a backend system where I would then like to upload the file to) and create the GUID:
public IActionResult Open()
{
ViewBag.MessageId = Guid.NewGuid().ToString();
return View("DocumentOpen", new List<string> { "in open event" });
}
Here is part of my View - I have many fields but I have created a view with only the upload widget:
@using Kendo.Mvc.UI
<form method="post" enctype="multipart/form-data">
<div class="k-content">
@(Html.Kendo().Upload()
.Name("attachments")
.Multiple(false)
.Async(async => async
.Save("UploadFileAsync", "Document", new { messageId = ViewBag.MessageId })
.Remove("RemoveFileAsync", "Document")
.AutoUpload(true)
)
)
</div>
</form>
Here the processing of the upload - as you can see the name and the parameter coincide (attachments) and the messageId has the GUID
[HttpPost]
public ActionResult UploadFileAsync(IEnumerable<HttpPostedFileBase> attachments, string messageId)
{
if (attachments == null) return Content("");
HttpPostedFileBase fileBase = attachments.FirstOrDefault();
var fileName = Path.GetFileName(fileBase?.FileName);
if (fileName != null)
{
var serverDirectory = System.Web.HttpContext.Current.Server.MapPath("~/" + messageId);
var serverPath = Path.Combine(serverDirectory, fileName);
fileBase.SaveAs(serverPath);
}
return Content("");
}
When running the code I get a GUID in the messageId field, the attachments field has a count of 0 i.e. It is *not* null. I have tried multiple examples here but am always getting the same error.
Any ideas?
PS: I cannot upload the project as it needs a backend document management system :(
MVC 5; .Net Core; Visual Studio 2017; Telerik 2019.2.514
I have a grid that uses SetOptions to load the users saved state. I am using incell editing. After using setOptions my events for Editable no longer get hit. Is there something I have to set manually after this like with the command buttons?
--Below I reassign the btnEdit event to the command button
var options = JSON.parse(response.myOptions);
options.columns[0].command[0].click = btnEdit;
grid.setOptions(options);
--My cell from grid
columns.Bound(p => p.ClearedBy).Title(text: "Cleared by").Editable("ClearedByEditable").Lockable(true);
--My Editable Event
function ClearedByEditable(e) {
Alert("I am here");
return false;
}
Hello,
In my current project we are facing some issues regarding XSS using the Editor in MVC. We already use the AntiXss library to "clean" the html posted to the server but we are facing the following difficulty.
In the editor "Insert Hyperlink" functionality, we have been warned that a possible script can be run by inserting malicious content to the Tooltip field.
For example look at "Hyperlink xss example.png".
I have already reviewed the documentation Telerik provides regarding this XSS but didn't find anything related to this particular issue.
Is there a way to remove the Tooltip field from the Insert Hyperlink form? (Using MVC, not Jquery). Or any other possible solution for this problem.
Thanks
Hi,
For a project I'm required to use Bootstrap 4, which in turn requires jQuery 3.+ (currently using 3.4.1).
While Kendo UI officially only supports jQuery 1.12.4, I've been using jQuery 3.+ without any problems, until now.
I'm exporting HTML into PDF using the Kendo UI Drawing functionality (snippet below). This snippet generates the PDF document with content without problems when using jQuery 1.12.4 or 2.2, but fails to add content when using jQuery 3.+. I've tried versions 3.0.0, 3.3.1 and 3.4.1 without success. Browsers I've tested: Firefox 67/68, Internet Explorer 11 and Chrome 75.
Unfortunately I'm unable to downgrade jQuery version due to Bootstrap 4 requirement, and would like to ask how I can solve this issue using jQuery 3.4.1 (using Kendo UI for MVC version 2019.2.619).
Thanks, Matthijs
<
div
class
=
"container"
>
<
div
class
=
"btn btn-primary"
id
=
"pdf-export"
>PDF Export</
div
>
<
div
class
=
"export-to-pdf"
>
<
div
>This is PDF content for page 1.</
div
>
</
div
>
<
div
class
=
"export-to-pdf"
>
<
div
>This is PDF content for page 2.</
div
>
</
div
>
<!-- etc.. -->
</
div
>
$(document).ready(
function
() {
$(
"#pdf-export"
).click(
function
() {
createPDF();
});
});
function
createPDF()
{
kendo.pdf.defineFont({
"Lato"
:
"/Content/Fonts/Lato-Regular.TTF"
,
"Lato|Bold"
:
"/Content/Fonts/Lato-Bold.TTF"
,
"Lato|Bold|Italic"
:
"/Content/Fonts/Lato-BoldItalic.TTF"
,
"Lato|Italic"
:
"/Content/Fonts/Lato-Italic.TTF"
});
var
root =
new
kendo.drawing.Group();
$(
'.export-to-pdf'
).each(
function
() {
kendo.drawing.drawDOM(
this
)
.then(
function
(group) {
group.options.set(
"pdf"
, {
margin: {
left:
"1cm"
,
right:
"1cm"
,
top:
"1cm"
,
bottom:
"1cm"
,
}
});
root.append(group);
});
});
root.options.set(
"pdf"
, {
multiPage:
'true'
});
kendo.drawing.exportPDF(root).done(
function
(data) {
kendo.saveAs({
dataURI: data,
fileName:
"DocumentName.pdf"
,
proxyURL:
"@Url.Action("
PdfExport
")"
,
forceProxy:
true
});
});
}
Hi,
I try to do that in asp.net mvc : http://dojo.telerik.com/UViSA/13
I want to add item in a multiselect control and after i want to select it.
It work find to add in datasource of my multiselect but i can't select my new item by code (this.value(add);) .
i don't think it the new item the problem because i can't select a existing item. I tried to select a existing element in this event and a had the same error.
I add in attach files a print screen of my error ("Failed to execute 'removeChild' on 'Node' : Parameter 1 is not of type 'Node'....)
This is my code :
@(Html.Kendo().MultiSelectFor(model => model.LesDestinataires)
.Name("LesDestinataires")
.AutoBind(true)
.Filter("contains")
.DataTextField("NomComplet")
.DataValueField("AdresseCourriel")
.Events(e =>
{
e.Change("onChange").Filtering("onFiltering");
})
.DataSource(source =>
{
source.Read(read =>
{
read.Action("ObtenirCourriels", "Assignation");
//read.Type(HttpVerbs.Post);
})
.ServerFiltering(false);
}
)
.HtmlAttributes(new { style = "width:350px;" })
)
after my event : (the problem it at this line : this.value(add);)
function onFiltering(e)
{
var filter = e.filter;
if (filter.value.indexOf(";") > 0) {
var newtag = filter.value.replace(";","");
var values = this.value().slice();
//e.preventDefault();
var ajout = {NomComplet: newtag ,AdresseCourriel: newtag };
this.dataSource.add(ajout);
this.dataSource.filter({});
var add = [newtag];
if (values.length> 0) {
var merge = $.merge(add, values);
this.value($.unique(merge));
} else {
this.value(add);
}
this.trigger("change");
//this.dataSource.refresh(); //This don't work
}
}
My read.action to fill multiselect :
public JsonResult ObtenirCourriels()
{
List<
Mentore
> maSource = db.Mentores.ToList();
var lstMentores = maSource.Take(1).Select(s => new { NomComplet = s.NomComplet_Mentore, AdresseCourriel = s.Courriel_Mentore }); //Take(1) to just fill with one item my multiselect
return Json(lstMentores, JsonRequestBehavior.AllowGet);
}
Thank for your help!
Hello.
I need to disable/enable a completely the way to edit my grid (batch mode).
Any suggestion to do it via javascript on the .Editable(editable => editable.Mode(GridEditMode.InCell))?
@(Html.Kendo().Grid<
Haz.ViewModels.Exp.SommaireDetailExDRModel
>()
.Name("gridDetailsEx")
.Columns(columns =>
{
...
})
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.HtmlAttributes(new { style = "font-size:11px;height: 200px;" })
.Scrollable()
.Selectable(s => s.Enabled(true))
.Sortable()
.Resizable(s => s.Columns(true))
.Filterable()
.Pageable(pageable => pageable
.Refresh(true)
.ButtonCount(5))
.Events(events => events
.Change("onChange").DataBound("onDataBound").Edit("onEdit").SaveChanges("onSaveChanges"))
...
Thanks to everyone.
Hi does anyone have a working example of loading a previous saved state when the grid first loads, and saving the filters/sort/column order when they are changed?
this needs to be completely seamless to the user (no save/load buttons), and I would prefer not to save/load the entire grid state from getOptions, just the filters/sorts/columnorder/page
note: I've already looked through the examples here: https://www.telerik.com/support/code-library/preserve-grid-state-in-a-cookie and here: https://demos.telerik.com/kendo-ui/grid/persist-state
the current issue I am running into is if I save the current state in the databound event (calling get-options), I can never retrieve them on page load as the databound event fires (saving empty state) before I would be able to retrieve the state from an external method (ie. trying to load on document ready).
the only workaround I can think of at this point is to load the settings from the databound event too, but flag it somehow so it only does so on first load.
Hi,
I need access to old version who support .net framework 4.6.1
Admin can help me please?