mortazavi
mortazavi

Reputation: 401

about kendo ui upload in mvc3

I want to use kendo ui q2 2012 in mvc3. i use the way of this link:

http://docs.kendoui.com/documentation/getting-started/using-kendo-with/aspnet-mvc/introduction

but in my razor view , instead of showing this:

 @(Html.Kendo().Upload()
            .Name("files")
        )

it shows this:

@Kendo.Mvc.UI.Upload 

and i can't use it. help plz. thanks...

another question is that can i use Telerik.Web.UI in mvc3? when i add it to my project same kendo that i said above, it doesn't show htmlHelper type.

Upvotes: 1

Views: 2672

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30671

You can check the upload overview help topic. It shows how to configure and use a Kendo Upload in ASP.NET MVC. Here is the relevant code:

View (Razor):


@(Html.Kendo().Upload()
        .Name("attachments")
        .Async(async => async
            .Save("Save", "Home")
        )
)

Controller:


public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments)
{
    // The Name of the Upload component is "attachments"
    foreach (var file in attachments)
    {
        // Some browsers send file names with full path. We only care about the file name.
        var fileName = Path.GetFileName(file.FileName);
        var destinationPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);

        file.SaveAs(destinationPath);
    }

    // Return an empty string to signify success
    return Content("");
}

Upvotes: 1

Related Questions