Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有html.radiobutton ASP.NET MVC的单选按钮_Html_Asp.net Mvc - Fatal编程技术网

带有html.radiobutton ASP.NET MVC的单选按钮

带有html.radiobutton ASP.NET MVC的单选按钮,html,asp.net-mvc,Html,Asp.net Mvc,我是所有ASP.NETMVC东西的新手,我正在为我的项目做一些测试。我想问一下,如何从html.radiobutton函数引入javascript函数调用。例如,您将如何声明: 使用html.radiobutton。我一直在寻找一些文档,但我没有真正理解,我想这与html对象属性有关,但我并不真正了解语法,也没有找到任何示例 提前谢谢大家:) vikitor将属性定义为匿名对象 <%= Html.Radiobutton( "Kingdom",

我是所有ASP.NETMVC东西的新手,我正在为我的项目做一些测试。我想问一下,如何从html.radiobutton函数引入javascript函数调用。例如,您将如何声明:

使用html.radiobutton。我一直在寻找一些文档,但我没有真正理解,我想这与html对象属性有关,但我并不真正了解语法,也没有找到任何示例

提前谢谢大家:)
vikitor将属性定义为匿名对象

 <%= Html.Radiobutton( "Kingdom",
                       "All",
                       true,
                       new { onclick = "GetSelectedItem(this);" } ) %>

或者更好的是,使用javascript(例如使用jQuery)悄悄地应用处理程序


$(函数(){
$('input[name=Kingdom]')。单击(函数(){
GetSelectedItem(this);//或者将代码内联到这里
});
});

非常感谢!我找了很长一段时间,没有找到一个正确的答案来回答我的问题。问候语
 <%= Html.RadioButton( "Kingdom", "All", true ) %>

 <script type="text/javascript">
     $(function() {
         $('input[name=Kingdom]').click( function() {
             GetSelectedItem(this);  // or just put the code inline here
         });
     });
 </script>