添加onclick事件Html.RadioButton [英] Add OnClick Event to Html.RadioButton

查看:415
本文介绍了添加onclick事件Html.RadioButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是,当用户点击一个单选按钮来调用JavaScript程序。我有一些字段启用/禁用当这种情况发生。然而,当我进入

What I want to do is to call a JavaScript routine when the user clicks on a radiobutton. I've some fields to enable/disable when this happens. However, when I enter

 <%=Html.RadioButton("obp17", "57", ViewData.Eval("obpValue17").ToString().Equals("57"), new {@onclick = "Yes()"})%>

我得到一个型或预期的错误尝试添加的点击数事件时。这应该是容易的,但没有我发现样本似乎工作。领先的@是我发现的所有例子常见的,但别的东西似乎缺少。

I'm getting a "type or with" expected error when trying to add the onlick event. This should be easy, but none of samples I've found seem to work. The leading "@" is common in all the examples I've found, but something else seems to be missing.

是的,我知道检查真的方法是矫枉过正,但它是用特殊用途code发生器创建的,所以它不是任何额外的工作。

And yes I know the way of checking for "true" is overkill, but it is created with a special purpose code generator, so it wasn't any extra work.

有什么想法?

推荐答案

你有是()函数在code正确定义。更换是()JavaScript的alert()函数,其是否正常工作,则c您发布的$ C $的行确定。

Do you have Yes() function correctly defined in your code. Replace Yes() to the javascript alert() function, if that works, then the line of code you posted is OK.

另外,请在这里发表是()函数,我觉得可能会有一些错误存在。

Also, please post Yes() function here, and I think there may be some error there.

这篇关于添加onclick事件Html.RadioButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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