将javascript变量传递给razor [英] Pass javascript variable to razor

查看:115
本文介绍了将javascript变量传递给razor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有剃刀代码。在代码中,我想将两个参数传递给控制器​​。

一个来自模型,另一个来自所选项目来自下拉列表。

 $(document).ready(function(){
$(#Languages)。change(function(){
var value = $(this).find('option:selected')。val();
@ Html.Action(Index,MyController,new {id = model.Guid,name =值);
});
});



但我收到错误

当前上下文中不存在名称'value'





我尝试过: < br $> b $ b

谷歌搜索

将javascript变量传递给razor 

解决方案

< blockquote>(document).ready(function(){


(#Languages)。change(function(){
var value =


(this).find('option:selected')。val();
@ Html.Action(Index,MyController,new {id = model.Guid,name = value);
});
});



但我收到错误

名称'value'不存在于当前背景





我尝试过的事情:



google search

将javascript变量传递给razor 


I have razor code. During the code, I want to pass two parameters to the controller.
One is from the model, the other one value is from the selected item from the drop down list.

$(document).ready(function () {
            $("#Languages").change(function () {
                var value = $(this).find('option:selected').val();
                @Html.Action("Index", "MyController",new{id=model.Guid, name= value);
            });
        });


But I get the error

the name 'value' does not exist in the current context



What I have tried:

google search

pass javascript variable to razor

解决方案

(document).ready(function () {


("#Languages").change(function () { var value =


(this).find('option:selected').val(); @Html.Action("Index", "MyController",new{id=model.Guid, name= value); }); });


But I get the error

the name 'value' does not exist in the current context



What I have tried:

google search

pass javascript variable to razor


这篇关于将javascript变量传递给razor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆