剃刀编辑器,用于复选框事件绑定 [英] razor editorfor checkbox event binding

查看:105
本文介绍了剃刀编辑器,用于复选框事件绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将事件绑定到@ html.editorfor

I cant bind event to @html.editorfor

我听说它可能与"class"属性的存在有关,但我看不到任何联系.

I've heard it might be connected to presence of "class" attribute but I can see no connection whatsoever.

@Html.EditorFor(model => model.SameAsBaseAddress, new { @onclick = "checkboxcheck()" })

function checkboxcheck() {
    //blah...
}

当我使用firebug调试并手动添加处理程序时,一切正常. TextBoxFor,RadioButtonFor等在剃刀事件绑定方面没有问题.

When I debug with firebug and add handler manually all works fine. TextBoxFor, RadioButtonFor etc. have no problems with razor event binding.

该怎么办?

推荐答案

EditorFor扩展名没有像TextBoxFor这样的参数htmlAttributes,请参见:

The EditorFor extension doesn't have an argument htmlAttributes like the TextBoxFor, see: http://msdn.microsoft.com/en-us/library/system.web.mvc.html.editorextensions.editorfor%28v=vs.118%29.aspx

我建议您将EditorFor更改为此问题建议创建一个编辑器模板.

I suggest you change EditorFor to CheckBoxFor, or if you do want to use the EditorFor, this question suggests to create an editor template.

这篇关于剃刀编辑器,用于复选框事件绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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