Telerik Forums
UI for ASP.NET MVC Forum
3 answers
1.3K+ views

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 :(

Ianko
Telerik team
 answered on 16 Jul 2019
2 answers
83 views

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;

}

Tsvetomir
Telerik team
 answered on 16 Jul 2019
2 answers
334 views

     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

 

 

Dimitar
Telerik team
 answered on 16 Jul 2019
3 answers
256 views

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
        });
    });
}

 

Ivan Danchev
Telerik team
 answered on 12 Jul 2019
3 answers
1.3K+ views
Hi ..
I have Master details datageid, in the row details i have tabstrip as partial view i'm loading each tabitem data with 
.LoadContentFrom("Action", "controller", new { Action parameters  });
i have listbox with the tabs names and in  the Change event i select the tabitem

everything work fine and the data loaded well, the problem is if i update the data and trying  to load the data in the details
can not  see the changes , looks like the data is in the cash
here is the details  code  : 

   @(Html.Kendo().DropDownList()
                  .Name("cmbCaseDetails_" + Model.CaseID)
                  .DataTextField("Text")
                  .DataValueField("Value")
                  .BindTo(new List<SelectListItem>() {
                          new SelectListItem() {
                            Text = "Fields", Value = "0" 
                          },
                          new SelectListItem() {
                            Text = "Descriptions", Value = "1"
                          },
                         new SelectListItem() {
                            Text = Relations", Value = "2"
                          }
                 })
                 .SelectedIndex(0)
                 .Events(e => e.Change("onDetailsListChanged"))
        )
       


 @(Html.Kendo().TabStrip()

                    .Name("tabDetails_" + Model.CaseID)
                  .HtmlAttributes(new { style = "background-color:#FFFFFF;border-style:none;" })
                  .Animation(animation => { animation.Enable(false); })
                  .Items(tabCaseDetails =>
                  {
                        tabCaseDetails.Add().Text("Fields")
                          .LoadContentFrom("CaseFields", "CaseDetails", new { CaseID = Model.CaseID });

                      tabCaseDetails.Add().Text("Descriptions")
                        .LoadContentFrom("CaseDescriptions", "CaseDetails", new { CaseID = Model.CaseID });

                      tabCaseDetails.Add().Text("Relations")
                        .LoadContentFrom("CaseRelations", "CaseDetails", new { CaseID = Model.CaseID });


                  })


<script type="text/javascript">
function onDetailsListChanged() {
      
        var val1 = "cmbDetails_" + "@Model.CaseID";
        var value = $("#" + val1).val();
        var id = "tabDetails_" + "@Model.CaseID";
        $("#" + id).kendoTabStrip().data("kendoTabStrip").select(value);  //set the selected tab page
     $("#" + id).kendoTabStrip().reload(value); // try to reload the data  not work

    }
</script>

Ianko
Telerik team
 answered on 12 Jul 2019
5 answers
685 views

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!

 

Ivan Danchev
Telerik team
 answered on 11 Jul 2019
2 answers
204 views

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.

Louis
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 10 Jul 2019
14 answers
420 views
Dear Sir or Madam,

we are right now in the trial period of the Telerik MVC suite.
Especially we are searching for a combination of a pivot grid control and a chart control.
You have on your demo website already such a demo for classic ASPX.
 
Can you also provide such a demo for MVC? This would help us a lot in the evaluation process.
 
Thanks a lot and best regards from Germany.

PS:
the documentation for the classic ASPX components (web form) seems to be much more elaborated than
the one for MVC ..it would be great if this could be aligned. Thanks!
Tsvetomir
Telerik team
 answered on 10 Jul 2019
4 answers
412 views

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.

 

Eyup
Telerik team
 answered on 09 Jul 2019
1 answer
101 views

Hi,

I need access to old version who support .net framework 4.6.1

Admin can help me please?

Missing User
 answered on 08 Jul 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?