Pass Javascript/html Variable as Parameter with Ke

2019-06-09 06:19发布

问题:

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)
    )
)

回答1:

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>)
    )
)