Telerik Forums
UI for ASP.NET Core Forum
1 answer
649 views

Hello,

 

where can I find the controller code for ASP.NET Core Upload Asynchronous Upload. Somehow when I trying to upload my file, I keep getting an error "failed to upload the file". below is what i have in my controller:

 


  public ActionResult Async_Save(IEnumerable<IFormFile> files)
        {
            // The Name of the Upload component is "files"
            string path = Path.Combine(_webHostEnvironment.WebRootPath, "FileSavePath");
            string DestinationPath = _configuration["DestinationPath"].ToString();
            if (files != null)
            {
                MoveFiles mf = new MoveFiles(); 
               
                foreach (var formFile in files)
                {
                    
                  

                    using (var stream = System.IO.File.Create(DestinationPath))
                    {
                        formFile.CopyTo(stream);
                    }

                    
                }
            }

This is my cshtml code:

 

any help will be apprecaited.
@using Kendo.Mvc.UI
<div style="margin-top:60px">
        <div class="block-section">
        @(Html.Kendo().Upload()
            .Name("files")
            .Async(a => a
                .Save("Async_Save", "Upload")
                .Remove("Async_Remove", "Upload")
                .AutoUpload(true)
            )
        )
    </div>
</div>

Vasko
Telerik team
 answered on 21 Aug 2023
1 answer
633 views
We are using Telerik for Asp.Net Core.  Using the file upload control in asynchronous chunk mode is there a maximum file size?  I know in synchronous mode its about 2gb, but I am curious if using chunk mode we can go past that since the file is uploaded in pieces.?
Vasko
Telerik team
 answered on 21 Aug 2023
1 answer
730 views

The form throws this exception when a User has Department. View with form:

@model DMDPace.DataAccess.DomainModels.User;

    @(Html.Kendo().Form<User>()
        .Name("User")
        .HtmlAttributes(new { action = "/Directory/User_Update", method = "POST" })
        .Layout("grid")
        .Grid(g => g.Cols(12).Gutter(20))
        .Items(i =>
        {
            i.Add().Field(e => e.DepartmentId).Label("Отдел").Editor(e => e.DropDownList()
                .DataTextField("Name")
                .DataValueField("Id")
                .DataSource(s =>
                {
                    s.Read(r => r.Action("GetDepartments", "Home"));
                }));
        }))


When I comment form code, it runs without errors.

 

User:

    public class User : Entity
    {
        public int? DepartmentId { get; set; }
        public Department Department { get; set; }
    }

Department:

public class Department : Entity
    {
        public virtual List<User> Users { get; set; }
    }

Startup:

services.AddControllers().AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

Endpoint which returns view:

[HttpGet("[controller]/User/{Id:int}")] public async Task<IActionResult> UserView(int id) { var entity = await _userObjectService.GetAll() .Include(e => e.Department) .Where(e => e.Id == id) .FirstOrDefaultAsync(); return View("User", entity); }

 

Telerik version - 2022.1.301.

kva
Top achievements
Rank 2
Iron
Iron
Iron
 updated question on 17 Aug 2023
1 answer
342 views

I have a dropdown editor in the partial view:

@(Html.Kendo().DropDownListFor(m => m.DepartmentId)
    .DataTextField("Name")
    .DataValueField("Id")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetDepartments", "Home");
        });
    })
    )

Which I use in grid by specifying partial view's file name:

 .EditorTemplateName("Department")
How to specify the same for the form's field?
Mihaela
Telerik team
 answered on 15 Aug 2023
1 answer
599 views

I have reached my wits end trying to figure out why my Kendo UI ListView will not display the data when using a very simple template.  The ListView is based on a IEnumerable Model.  I'm very frustrated at this point.  No errors in f12.  The template just does not display.  Checking in debugger the data is all there and the model passed back as Json to the view is populated.  I have triple checked the field names match in the template and model.

 

Update:  One more bit of info...even if the template is a simple thing like this it STILL does not show:

<script type="text/x-kendo-tmpl" id="template">
    <div>TEST TEMPLATE</div>
</script>

 

Relevant View Code:

<script id="templateTest" type="text/x-kendo-tmpl">
    <div>Accounts:</div>
    <div class="product-view k-widget">
        <dl>
            <dt>Bank Name</dt>
            <dd>#:BankName#</dd>
        </dl>
    </div>
</script>


@(Html.Kendo().ListView<PayrollAccountModel>()
    .Name("listViewTest")
    .AutoBind(false)
    .TagName("div")
    .ClientTemplateId("templateTest")
    //.ClientTemplateHandler("templateTest")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id("Id"))
        .Create(create => create.Action("PayrollAccount_Create", "DirectDeposit"))
        .Read(read => read.Action("PayrollAccount_Read", "DirectDeposit"))
        .Update(update => update.Action("PayrollAccount_Update", "DirectDeposit"))
        .Destroy(destroy => destroy.Action("PayrollAccount_Destroy", "DirectDeposit"))
    )
    .Editable().Deferred()
    )

 

Relevant Controller Code:

DirectDepositController:

public ActionResult PayrollAccount_Read([DataSourceRequest] DataSourceRequest request)
        {
            //create new listView item and add some test data
            List<PayrollAccountModel> Accounts = new()
            {
                new PayrollAccountModel { Id = 1, BankName = "Bangor Savings Bank", AccountNumber = "99999999", RoutingNumber = "123456789" },
            };

            return Json(Accounts.ToDataSourceResult(request));
        }

 

 

Any help would be hugely appreciated!

 

Thanks

Mihaela
Telerik team
 answered on 15 Aug 2023
1 answer
283 views

Hello i am using Oracle Database and have a model  called CableView Model  that i pass to grid  and CableInfoID is my  intended  id for the grid. I have issues updating grid data as always it returning 0 instead of a value.What am i doing wrong?

 

grid code

@(
                            Html.Kendo().Grid<DI_IPMS_KENDO.Models.CableViewModel>()
                                .Name("CableNetGrid")
                                .Columns(columns =>
                                {
                                    columns.Bound(p => p.CableInfoID);
                                    columns.Bound(p => p.CableId).Title("Cable").Width(100);
                                    columns.Bound(p => p.SwitchName).Width(100);
                                    columns.Bound(p => p.Port).Width(100);
                                    columns.Bound(p => p.TechnicianAssigned).Title("TechnicianAssigned").Width(150);
                                    columns.Bound(p => p.AvailableIp).Width(100);
                                    columns.Bound(p => p.SubnetMask).Width(100);
                                    columns.Bound(p => p.Comments).Width(100);
                                    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
                                })
                                .ToolBar(toolbar => toolbar.Create())
                                .Editable(editable => editable.Mode(GridEditMode.PopUp))
                                .Pageable()
                                .Sortable()
                                .Scrollable()
                                .Events(ev => ev.Edit("onEdit"))
                                .Events(ev => ev.BeforeEdit("onEdit"))
                                .Events(ev => ev.Cancel("onCancel"))
                                .HtmlAttributes(new { style = "height:430px;" })
                                .DataSource(dataSource => dataSource
                                .Ajax()
                                .PageSize(20)
                                .Events(events => events.Error("error_handler"))
                                .Model(model =>
                                {
                                    model.Id(p => p.CableInfoID);
                                    model.Field(id => id.CableInfoID).DefaultValue(-1);
                                })
                            .Create(update => update.Action("Cables_Create", "Home").Data("getData"))
                            .Read(read => read.Action("Cables_Read", "Home").Data("getID"))
                            .Update(update => update.Action("Cables_Update", "Home").Data("getData"))
                            .Destroy(update => update.Action("Cables_Destroy", "Home"))
                            )
                            )

 

 

 

 

       

 public class CableViewModel

    {
        [ScaffoldColumn(false) ]
        public int CableInfoID { get; set; }



        [Required]
        [DisplayName("Cable ID")]
        public string CableId { get; set; }


        [Required]
        [DisplayName("Switch Name")]
        public string SwitchName { get; set; }

        [Required]
        [DisplayName("Port")]
        public string Port { get; set; }

        [ScaffoldColumn(false)]
        public string ToolID { get; set; }
        //public int ?ToolRecID { get; set; }
        [ScaffoldColumn(false)]
        public int ToolRecID { get; set; }

        [UIHint("_AdminEmp")]
        [Required]
        [DisplayName("Technician Assigned")]
        public string TechnicianAssigned { get; set; }

        [DisplayName("Available IP")]
        public string AvailableIp { get; set; }

        [DisplayName("Subnet Mask")]
        public string SubnetMask { get; set; }

        [DisplayName("Gateway")]
        public string Gateway { get; set; }
        public string Comments { get; set; }
    }

 

 

i have  update method as follows ..please ignore other fields as i am returning from view or grid..

Everytime i try to update  the grid row the CableInfoID is 0 

  public ActionResult Cables_Update([DataSourceRequest] DataSourceRequest request, CableViewModel product, int ToolRecID, string toolID, string Empltext)
        {
            if (ModelState.IsValid && product != null)
            {

                // Create a new Product entity and set its properties from the posted ProductViewModel.
                var entity = new DiIpmsCableTeamCableInfo
                {
                    RecordId = product.CableInfoID,
                    CableId = product.CableId,
                    SwitchName = product.SwitchName,
                    Port = product.Port,
                    TechnicianAssigned = Empltext,
                    ToolId = product.ToolID,
                    ToolRecId = ToolRecID,
                    AvailableIp=product.AvailableIp,
                    SubnetMask=product.SubnetMask
                };

                // Attach the entity.
                _db.DiIpmsCableTeamCableInfos.Attach(entity);
                // Change its state to Modified so Entity Framework can update the existing product instead of creating a new one.
                _db.Entry(entity).State = EntityState.Modified;
                // Or use ObjectStateManager if using a previous version of Entity Framework.
                // northwind.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
                // Update the entity in the database.
                _db.SaveChanges();

            }

            // Return the updated product. Also return any validation errors.
            return Json(new[] { product }.ToDataSourceResult(request, ModelState));
        }

 

In the grid  update method 

Alexander
Telerik team
 answered on 14 Aug 2023
1 answer
129 views

When I add input for Id as said here https://docs.telerik.com/aspnet-core/html-helpers/layout/form/hidden-fields

i.Add().Field(f => f.Id).Editor(e => e.Hidden());

I got this text on my

Id:
hidden

How to get rid of it?

Also, I don't see input in the DOM tree, how Id will be transferred to the server?

Mihaela
Telerik team
 answered on 11 Aug 2023
1 answer
461 views
Default handler clears inputs values, but I want to set default values. I can accomplish this with my own handler, but I don't know how to remove default.
Mihaela
Telerik team
 answered on 11 Aug 2023
0 answers
124 views
I've upgraded to my project to ASP.NET Core from the MVC version and updated all of the Kendo scripts to version 2023.2.718, and the reload animation for many of my controls now looks like the attached image. 
Jonas
Top achievements
Rank 1
 asked on 10 Aug 2023
1 answer
202 views
Is there way to simply center the items on a Tool bar in the middle of the toolbar. 
Vasko
Telerik team
 answered on 10 Aug 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?