Changing the default "Select..." text on the button ASP.NET MVC

1 Answer 2267 Views
Upload
Mark
Top achievements
Rank 1
Mark asked on 09 Jan 2013, 11:26 AM
Hi!

I have the following problem: in the asp.net mvc Upload widget, I cannot change the text of the Upload widget. In this thread there is a solution for this problem, however it does not work in ASP.NET MVC!

My code is fairly simple, there is 
@(Html.Kendo().Upload()
      .Name(
"FilesToUpload")
)
in the cshtml and the following code in the header: 
$(document).ready(function() {
$("#FilesToUpload").closest(".k-upload").find("span").text("Select unit bulk upload file");
});
If there would be an event for the widget (e.g. loaded) I could subscribe to it, but now, the only solution is to use the HTML and js way of creating an Upload widget, which is far from optimal in an ASP.NET MVC project.

Thanks for the help!
Chris
Top achievements
Rank 1
commented on 09 Jan 2013, 12:30 PM

Hi mate,

I use ASP.NET MVC too, but dont use the wrappers.

If i understand you correctly, you want to change the text of the upload, that is by default "Select" ?

creating the object with jQuery you can do:
$("#attachments").kendoUpload({
    async: {
        autoUpload: true
    },
    localization: {
        select: 'any text',
        remove: '',
        cancel: ''
    }
});

It is also possible to replace the text completely with an image, which I have done, then looks much better.

So, if you are using the .NET kendo wrappers, try looking for a localization property in the intellisense.

or just create the object with jQuery as i do.
Better than using jQuery to change after created.

I hope this is useful to you.
Regards
Chris

Mark
Top achievements
Rank 1
commented on 19 Jan 2013, 08:18 PM

Hi Chris!

Thanks for the fast answer, but this doesn't quite solve the issue. Unfortunately there is no localization property which I can use to change the text of the Upload button. And I would like to stick to the fluent interface that is built upon the HtmlHelper class, because all of my code is done like that and I like uniformity in my code :)

However until I find a solution I will use the code u posted, thanks for that and if I find a solution I won't hesitate to share in this thread.

Cheers,
Márk

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 22 Jan 2013, 12:36 PM
Hi Mark,

You can set custom text on the "Select" button and stick to the fluent interface, using the Messages() method of the Mvc Wrappers. Here is an example:

@(Html.Kendo().Upload()
    .Name("FilesToUpload")
    .Messages( m => m.Select("Select unit bulk upload file"))
)

I hope this information solves your issue.

Kind regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Masaab
Top achievements
Rank 1
commented on 11 Apr 2014, 12:31 AM

I  am also using MVC (4) . The Code Runs Fine except for a little change. You need to access (".k-upload-button").
Here is the Correct Code..

$(document).ready(function() {
 $(
"#FilesToUpload").closest(".k-upload-button")
                    .find(
"span")
                    .text(
"Select unit bulk upload file");
                 }

Damir
Top achievements
Rank 1
commented on 19 Jul 2015, 04:41 PM

If the "Select Files..." message needed to get changed and you are using kendo UI uploadFile for MVC widget. I recommend to use the "Message" method, something like this below.

@(Html.Kendo().Upload()
.Name("member​Lo​goFile")
.Multiple(false)
.Messages(mess=>mess.Select("Upload Logo Image File"))
.Async(a => a
.Save("Save", "Home")
.Remove("Remove", "Home")
.AutoUpload(true)
)
.HtmlAttributes(new { accept= "image/*" })
)

Damir
Top achievements
Rank 1
commented on 19 Jul 2015, 04:45 PM

Sorry Reply the wrong post, here is what I do. 
If the "Select Files..." message needed to get changed and you are using kendo UI uploa for MVC widget. I recommend to use the "Messages" method, something like this below.
@(Html.Kendo().Upload()
.Name("member​Lo​goFile")
.Multiple(false)
.Messages(mess=>mess.Select("Upload Logo Image File"))
.Async(a => a
.Save("Save", "Home")
.Remove("Remove", "Home")
.AutoUpload(true)
)
.HtmlAttributes(new { accept= "image/*" })
)
Tags
Upload
Asked by
Mark
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or