在javascript中将参数从剑道窗口刷新传递到控制器操作

在javascript中将参数从剑道窗口刷新传递到控制器操作,javascript,asp.net-mvc,kendo-ui,kendo-window,Javascript,Asp.net Mvc,Kendo Ui,Kendo Window,我有一个简单的问题:有了剑道窗口,我可以像这样刷新它: window.refresh({ url: '@Url.Action("_EditScheduleInspectionForm", "TLM")', 我想向该控制器操作传递一个参数。我尝试了以下方法,效果良好: window.refresh({ url: '@Url.Action("_EditScheduleInspectionForm", "TLM", new { test = "test"})', 控制器 publi

我有一个简单的问题:有了剑道窗口,我可以像这样刷新它:

window.refresh({
    url: '@Url.Action("_EditScheduleInspectionForm", "TLM")',
我想向该控制器操作传递一个参数。我尝试了以下方法,效果良好:

window.refresh({
    url: '@Url.Action("_EditScheduleInspectionForm", "TLM", new { test = "test"})',
控制器

public PartialViewResult _EditScheduleInspectionForm(string test)
test
变量用传递的字符串“test”填充。但我不想硬编码字符串,我想在那里传递一个javascript变量,比如:

var test = "something";
window.refresh({
    url: '@Url.Action("_EditScheduleInspectionForm", "TLM", new { test = test})',

但上述方法不起作用,无法识别变量。如何实现这一点?

如果变量将成为字符串,则始终可以使用replace将静态值替换为变量值。请参阅下文:

var url = '@Url.Action("_EditScheduleInspectionForm", "TLM", new { test = "testvalue"})',,

var jsvariable = "something";

window.refresh({
url: url.replace("TLM",jsvariable ),
或者,您可以通过以下更简单的方式直接执行此操作:

var test = "something";
window.refresh({
url: '@Url.Action("_EditScheduleInspectionForm", "TLM", new { test = ' + test +'})',

第二个解决方案不起作用,但上面的方法很好。尽管我必须传递一个伪字符串以进行替换,但最终的行为正是我想要的。谢谢