0

Have a requirement to pass additional parameter with value of parameter set from javaScript or HTML field.

Example in below case how I can pass HTML element value or Javascript variable value to uploadID.

Note: Have limitation to use ViewModel in this place.

@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .Save("Save", "Upload", new { uploadID = "XXX" })
        .Remove("Remove", "Upload")
        .AutoUpload(true)
    )
)
2
  • Are you getting an error? What seems to be the issue? Commented Mar 14, 2017 at 19:35
  • Need to get JavaScript variable value in place of "XXX", as this controller is within server tag @(), cannot directly assign value. is there a way to get value of HTML hidden field for XXX Commented Mar 14, 2017 at 19:55

2 Answers 2

2

Try this out:

@(Html.Kendo().Upload()
    .Name("files")
    .Async(a => a
        .Save("Save", "Upload")
        .Remove("Remove", "Upload")
        .AutoUpload(true)
    )
    .Events(e => e
        .Upload(@<text>
            function(e) {    
                e.data = { uploadID: your_js_variable };
            }
        </text>)
    )
)
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. Able pass value and get at controller with this.
Need another Help. The JS variable assigned for e.data{}, is set to initial value set on page load and not reflecting the updated value set in html later. Is there any way to refresh Kendo Upload Controller to consider latest value
That's very interesting - I would have thought that Kendo was grabbing the value each time an upload is initiated. Perhaps try passing in a function instead (I've never tried this before so not sure if it's possible)? e.data = { uploadID: func_that_calculates_value() }; You may need to create a new question as it's a bit difficult to lay everything out in just the comments area.
2

Another way:

@Html.Kendo().Upload().Name("files").Async(a => a
.Save("Async_Save", "ActionCtl")
.Events(events => events.Upload("onUpload")))

<script>
function onUpload(e) {
                    e.data = { ItemBankId: @Model.ItemID };
                }
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.