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

7 posts, 1 answers
  1. Mark
    Mark avatar
    2 posts
    Member since:
    Oct 2012

    Posted 09 Jan 2013 Link to this post

    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!
  2. Chris
    Chris avatar
    6 posts
    Member since:
    Jun 2012

    Posted 09 Jan 2013 Link to this post

    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

  3. Kendo UI is VS 2017 Ready
  4. Mark
    Mark avatar
    2 posts
    Member since:
    Oct 2012

    Posted 19 Jan 2013 Link to this post

    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
  5. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 22 Jan 2013 Link to this post

    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!
  6. Masaab
    Masaab avatar
    15 posts
    Member since:
    Nov 2013

    Posted 10 Apr 2014 in reply to Mark Link to this post

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

  7. Damir
    Damir avatar
    5 posts
    Member since:
    Mar 2014

    Posted 19 Jul 2015 in reply to Chris Link to this post

    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/*" })
    )

  8. Damir
    Damir avatar
    5 posts
    Member since:
    Mar 2014

    Posted 19 Jul 2015 in reply to Mark Link to this post

    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/*" })
    )
Back to Top
Kendo UI is VS 2017 Ready